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 PRs from forks #13

Merged
merged 16 commits into from
Oct 10, 2020
Merged

Allow PRs from forks #13

merged 16 commits into from
Oct 10, 2020

Conversation

jesusvasquez333
Copy link
Owner

@jesusvasquez333 jesusvasquez333 commented Oct 10, 2020

This resolves #9.

The previous version didn't work when opening PRs from forks due to Github actions running with read-only permissions from forks.

Fortunately, Github recently added a new trigger event pull_request_target which behaves in an almost identical way to the pull_request event, but the action runs in the base of the pull request and will therefore have write permission.

However, as the action runs in the base of the pull request, the pull request number is not available in the environmental variables, which the code was using to extract the number automatically. Therefore, to use this new event, a new input argument was added in order to pass the pull request number which is available in the GitHub context ${{ github.event.pull_request.number }}.

So, for example, to allow PR from forks, in your workflow YAML file you should trigger with:

on:
  pull_request_target:
   types: [opened, labeled, unlabeled, synchronize]

and use these steps (you just need to add the extra pull-request-number input):

uses: jesusvasquez333/verify-pr-label-action@v1.3.1
with:
    github-token: '${{ secrets.GITHUB_TOKEN }}'
    valid-labels: 'bug, enhancement'
    pull-request-number: '${{ github.event.pull_request.number }}'

The changes are backward compatibles, so you can still use the pull_request tigger event, and in that case you don't need to specify the input pull-request-number as you did before. This however won't work with PRs from forks.

@jesusvasquez333 jesusvasquez333 added the enhancement New feature or request label Oct 10, 2020
@jesusvasquez333 jesusvasquez333 self-assigned this Oct 10, 2020
@jesusvasquez333 jesusvasquez333 merged commit d90335a into master Oct 10, 2020
@jesusvasquez333 jesusvasquez333 deleted the debug branch October 10, 2020 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stacktrace due to 403 error with incomplete info
1 participant