gr2m / create-or-update-pull-request-action

A GitHub Action to create or update a pull request based on local changes
ISC License
68 stars 25 forks source link

Create a Pull Request on a separate repository. #667

Open vinibosch opened 8 months ago

vinibosch commented 8 months ago

Hello, do you have any plans to add support for creating Pull Requests on a different repository?

gr2m commented 8 months ago

You can do that already today, you just have to checkout the repository where you want to create the pull request. You can't do that with the provided secrets.GITHUB_TOKEN as it's scoped to only the current repository, I recommend to register a GitHub app with contents:write and pull_requests:write permissions and then use https://github.com/actions/create-github-app-token to create a token and use that token in actions/checkout

lfgcampos commented 1 month ago

hi @gr2m, is there a way to checkout 2 repos but open a PR against a specific one only?

eg:

# default action stuff
...
    steps:
      - name: Checkout repo1
        uses: actions/checkout@v4
        with:
          path: repo1
      - name: Checkout repo2
        uses: actions/checkout@v4
        with:
          repository: org/repo2
          token: ${{ secrets.TOKEN_1 }}
          path: repo2

# change files based on repo1 to be commited on repo2
...

      - name: Commit file to repo2 repo
        uses: gr2m/create-or-update-pull-request-action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.TOKEN_2 }}
        with:
          branch: "auto-repo2-update"
          commit-message: "repo2 auto-update"
          title: repo2 updates
          assignees: ${{ github.actor }}
          auto-merge: squash

I've tried with and without the path: repo2/ and it doesn't work.

The error is (with it):

Error: Command failed with exit code 128 (Unknown system error -128): git status repo2/

Without it:

Error: Command failed with exit code 128 (Unknown system error -128): git status
gr2m commented 1 month ago

I don't know, I'd have to look into it myself. I suggest you fork the repo and experiment to find out