Skip to content

Commit 16b9c67

Browse files
committed
fix(ci): require maintainer association for /update-snapshots trigger
The issue_comment trigger previously ran for any commenter on a PR. On a public repo this lets drive-by users trigger a job with contents:write that checks out the PR branch, runs playwright --update-snapshots, and pushes a [skip ci] commit. Gate the issue_comment path on author_association being OWNER, MEMBER or COLLABORATOR. workflow_dispatch is unchanged (already requires repo write access).
1 parent 6b12fff commit 16b9c67

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

.github/workflows/update-snapshots.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ permissions:
1616

1717
jobs:
1818
update-snapshots:
19-
# Run on workflow_dispatch OR when someone comments "/update-snapshots" on a PR
19+
# Run on workflow_dispatch OR when a maintainer comments "/update-snapshots" on a PR.
20+
# author_association check prevents arbitrary commenters from triggering a job with
21+
# contents:write that pushes a [skip ci] commit to the PR branch.
2022
if: >
2123
github.event_name == 'workflow_dispatch' ||
22-
(github.event.issue.pull_request && contains(github.event.comment.body, '/update-snapshots'))
24+
(github.event.issue.pull_request &&
25+
contains(github.event.comment.body, '/update-snapshots') &&
26+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
2327
runs-on: ubuntu-latest
2428
steps:
2529
- name: Get PR branch

0 commit comments

Comments
 (0)