TimonVS / pr-labeler-action

Automatically labels your PRs based on branch name patterns like feature/* or fix/*.
MIT License
249 stars 52 forks source link

Fix reading config file when pull request from forked repository #80

Open nowsprinting opened 1 year ago

nowsprinting commented 1 year ago

Changes

Reason

refs #25

nowsprinting commented 1 year ago

Inner pull request example (regression test) https://github.com/nowsprinting/pr-labeler-action-test/pull/4

Forked pull request example (fixed this issue, read config from base.ref) https://github.com/nowsprinting/pr-labeler-action-test/pull/5

TimonVS commented 1 year ago

Thanks for the contributions and a special thank you for including test results 🙌

I suppose this is necessary because it doesn't have permissions to read the fork's config file when using the pull_request_target event?

nowsprinting commented 1 year ago

I suppose this is necessary because it doesn't have permissions to read the fork's config file when using the pull_request_target event?

No. This problem (refs #25 ) has two steps.

  1. Readonly GITHUB_TOKEN and not read secret on pull_request trigger So pr-labeler-action is not work. (See: https://github.com/nowsprinting/pr-labeler-action-test/pull/6 ) Require using pull_request_target trigger.

  2. fork-repo's head.ref is not exist in base-repo Using base.ref. Fixed it in this PR.