3

Is there a way to tell GitHub to automatically create a pull request from an API providing JSON content and merge it into my project?

I want to:

  1. Edit files on a platform (I control the platform) using my own production editors/tools.
  2. Have GitHub request it (REST), then create a PR or a commit, so people can collaborate on it with forks/GitHub project management.
  3. Push from GitHub back to the platform for publishing.

3 is no problem, but 2 I can't find documentation for if it's even possible.

4
  • The answer can just be no and I'll accept that. Commented Feb 3, 2022 at 20:52
  • github needs an action to trigger the github-action run - dozens of actions are supported so maybe as part of (1) you could update something on the github repo or you could run the action on a schedule (docs.github.com/en/actions/using-workflows/…) - you could try github.com/marketplace/actions/http-request-action for the REST bit (2) - then github.com/marketplace/actions/create-pull-request for the PR (2) Commented Feb 3, 2022 at 21:02
  • @PJFanning I see thanks, so either a schedule or do something arbitrary to trigger the action, like creating a new issue? Then the actions can create the PR. Is it just the PR or is it capable of creating the new files the PR requires? That can all be done through the actions? If so go ahead and leave the answer and I will give it to you. Commented Feb 4, 2022 at 22:25
  • Okay after a lot more poking now I understand how this works. The Github documentation doesn't cover anything because the default actions are extremely limited. Instead there's a marketplace of actions that has the functionality I need, including httpr, create file, create PR. You string them together to do this. Actions can be triggered manually as well as on a timer so that's fine. Thanks to @PJFanning putting me in the right direction. Commented Feb 6, 2022 at 12:54

1 Answer 1

2
name: Manual workflow
on:
  workflow_dispatch:
jobs:
  makefiles:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
    - uses: actions/checkout@v2
    - name: Getting
      uses: fjogeleit/http-request-action@master
      id: myRequest
      with:
        url: 'https://domain/api/file'
        method: 'GET'
    - name: Show File
      run: echo ${{ steps.myRequest.outputs.response }}
    - name: Create A File
      uses: 1arp/[email protected]
      with:
        path: 'src'
        file: 'foo.bar'
        content: ${{steps.myRequest.outputs.response}}
    - name: final commit
      uses: zwaldowski/git-commit-action@v1
      id: git_commit
    - name: show
      run: echo "${{ steps.git_commit.outputs.sha }}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.