Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to open PR in another repository #76

Closed
fbiville opened this issue Jun 23, 2021 · 10 comments
Closed

Allow to open PR in another repository #76

fbiville opened this issue Jun 23, 2021 · 10 comments

Comments

@fbiville
Copy link

No description provided.

@vsoch
Copy link
Owner

vsoch commented Jun 23, 2021

You should be able to do this, but you’ll need to use a personal access token.

@fbiville
Copy link
Author

Thanks for your quick reply!
So if I've got repo A, branch X, I can already open PRs against repo B targeting branch Y?
How does the configuration look like in that case? I could not figure out.

@vsoch
Copy link
Owner

vsoch commented Jun 24, 2021

Use the environment variable PULL_REQUEST_REPOSITORY. Did you look at the README at all? https://github.com/vsoch/pull-request-action

@fbiville
Copy link
Author

fbiville commented Jun 28, 2021

Yes I did, and I tried it without success.

Anyway, after reviewing GitHub API docs, I might be able to make it work with a combination of PULL_REQUEST_FROM_BRANCH (with the qualified branch name: user:branch and PULL_REQUEST_REPOSITORY.

This use case would be worth documenting in your README.

@fbiville
Copy link
Author

fbiville commented Jun 28, 2021

I managed to make it work 🥳

Here is the pipeline I set up on the source repo (fbiville/commit-fwd-source-repo):

name: Commit forward
on:
  push:
    branches: ['4.3']
jobs:
  commit-forward:
    name: PullRequestAction
    runs-on: ubuntu-latest
    steps:
      - name: pull-request-action
        uses: vsoch/pull-request-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.FORWARD_TOKEN }}
          # source
          PULL_REQUEST_FROM_BRANCH: "fbiville:4.3"
          # target
          PULL_REQUEST_REPOSITORY: fbiville-testing/commit-fwd-source-repo
          PULL_REQUEST_BRANCH: "4.3"

This forwards every commit as PR from the 4.3 branch of fbiville/commit-fwd-source-repo to the 4.3 branch of fbiville-testing/commit-fwd-source-repo.
Note that it required an explicit user-defined personal token for it to work, as you initially suggested.

@fbiville
Copy link
Author

For consistency's sake, it might be worth adding a PULL_REQUEST_FROM_USER_OR_ORG, given there is already PULL_REQUEST_FROM_BRANCH? This would provide a better symmetry between the source and target repo/branch.

@vsoch
Copy link
Owner

vsoch commented Jun 28, 2021

@fbiville you don’t get to dictate that - the token decides. I’m not sure I see your logic here.

@fbiville
Copy link
Author

fbiville commented Jun 29, 2021

What I'm trying to suggest is to allow both the current form:

          PULL_REQUEST_FROM_BRANCH: "fbiville:4.3"

and an alternative way:

          PULL_REQUEST_FROM_USER_OR_ORG: "fbiville"
          PULL_REQUEST_FROM_BRANCH: "4.3"

My PAT does not limit me to only github.com/fbiville, or? I could push to repositories of other organizations I'm part of, or am I mistaken?

@vsoch
Copy link
Owner

vsoch commented Jun 29, 2021

Ah I understand. That would only work if you trigger the workflow for any repository in an organization. How would you do that for one workflow?

@fbiville
Copy link
Author

I'm already doing this to sync https://github.com/fbiville/commit-fwd-source-repo (where the above configuration lives) and its fork https://github.com/fbiville-testing/commit-fwd-source-repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants