Skip to content

Commit 7698525

Browse files
Fix metadata reminder to work with forks (#1742)
This PR updates the reminder to modify the `dateOfLastModification` so it will work when PRs are opened from forks. One consequence is that the check for changed files must now take place within the body of the script by calling the Github CLI directly, because the action's paths check doesn't work as expected when the workflow trigger is `pull_request_target`. **Potential risks**: The new event trigger means the associated GITHUB token will have elevated privileges, but the scope is limited to posting a comment on the PR, and no code is checked out and no secrets are involved, so the risk is minimal.
1 parent 572781e commit 7698525

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

.github/workflows/update-metadata-reminder.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Reminder to update demo metadata
22
on:
3-
pull_request:
3+
pull_request_target:
44
types: [opened, reopened]
5-
paths:
6-
- demonstrations_v2/**
75

86
jobs:
97
reminder:
@@ -12,6 +10,13 @@ jobs:
1210
- uses: actions/github-script@v7
1311
with:
1412
script: |
13+
const files = await github.paginate(
14+
github.rest.pulls.listFiles,
15+
{ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.issue.number }
16+
);
17+
const touchesDemos = files.some(f => f.filename.startsWith('demonstrations_v2/'));
18+
if (!touchesDemos) return;
19+
1520
github.rest.issues.createComment({
1621
issue_number: context.issue.number,
1722
owner: context.repo.owner,

0 commit comments

Comments
 (0)