Skip to content

Commit 67e7306

Browse files
thc1006Gui-FernandesBR
authored andcommitted
CI: run the changelog job for pull requests from forks
`Populate Changelog` fails for every pull request opened from a fork, and only those. GitHub withholds secrets from a `pull_request` run whose head is a fork, so `secrets.RELEASE_TOKEN` is empty and the checkout stops after a few seconds: ##[error]Input required and not supplied: token The effect is that no outside contribution gets a changelog entry. RocketPy-Team#1102, RocketPy-Team#1103 and RocketPy-Team#1108 all landed without one and had to be added by hand. `pull_request_target` receives secrets because it runs in the context of the base repository. That is also why it needs care, and why this belongs on master rather than develop: the workflow definition is read from the default branch, so a copy that only exists on develop would never be loaded. Nothing from the pull request is executed here. The checkout is `ref: develop`, the updater is inline in the workflow rather than a script from the tree, and the title and labels reach Python through the environment instead of the shell. `permissions` drops to `contents: read`. The job's writes go through RELEASE_TOKEN, which the checkout persists, so GITHUB_TOKEN does not need write and should not have it now that the trigger runs with secrets available. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent cb6106a commit 67e7306

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎.github/workflows/changelog.yml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
name: Populate Changelog
22
on:
3-
pull_request:
3+
# `pull_request_target`, not `pull_request`. Secrets are withheld from a
4+
# `pull_request` run whose head is a fork, so RELEASE_TOKEN arrived empty and
5+
# the checkout below failed for every outside contribution.
6+
#
7+
# Nothing from the pull request is executed. The checkout is `ref: develop`,
8+
# and the updater is inline below, which under this trigger is read from the
9+
# default branch rather than from the merged head.
10+
pull_request_target:
411
types: [closed]
512
branches:
613
- develop
714

15+
# Read, because the job's own writes go through RELEASE_TOKEN. This trigger runs
16+
# with secrets available, so GITHUB_TOKEN should not also carry write.
817
permissions:
9-
contents: write
18+
contents: read
1019

1120
jobs:
1221
Changelog:

0 commit comments

Comments
 (0)