-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
refactor(ci/pr-review): use workflow_call
instead of workflow_run
event (v2)
#30064
Conversation
Co-authored-by: Brian Thomas Smith <[email protected]>
Thanks for V2, Yin. I think we can merge later today keep an eye on CI again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also leaving a +1, will merge this one later this afternoon and monitor builds 🔬
@yin1999 @caugner you can see the new workflow in action here: https://github.com/mdn/content/actions/runs/6772741006?pr=28731 Well done 🙌🏻 |
Description
This PR mainly switch to
workflow_call
instead ofworkflow_run
event to prevent calling "PR review companion" when not necessary.To achieve this, and take this opportunity to improve the code, the following changes were made:
pull_request_target
event instead ofpull_request
, with the former event, theGITHUB_TOKEN
has write permissions and the jobs could access GitHub secrets (we are using secrets to store the AK, SK).read-all
to avoid accidental writes to the repo.if
condition to skip unnecessary runs,Set the permissions of "review" job to
write-all
, so the deployer could create comment in PRs.Add
secrets: inherit
to inherit the secrets from the parent workflow so the reusable workflow could access all secrets. (tested in: remove some lines for test yin1999/content#8, https://github.com/yin1999/content/actions/runs/6769815012/job/18397036827?pr=8#step:10:34)actions/download-artifact
instead of js scripts, as the shared "PR review companion" workflow is a spread job in "PR test" now, we could use this action to download and unzip artifacts (simplifies the steps).Security statement
Because the
GITHUB_TOKEN
generated in workflows that triggered bypull_request_target
event has write permissions, we need to avoid malicious damage to the repo by the PR author.read-all
(as we still need theGITHUB_TOKEN
to access some resouces).pull_request_target
event would trigger the workflow runs with themain
version of workflows (including the shared workflows - "PR review companion"). This has been tested by Onkar - Test workflow_call yin1999/content#6, and has been documented by GitHub Docs:pull_request_target
event could also access GitHub secrets. But GitHub Actions can only read a secret if you explicitly include the secret in a workflow.Related issues and pull requests
implementation of: #28579 (comment)
Previous attempt: #28617