fix(ci): thank first contributors on push, not on the fork's PR event - #25
Conversation
The workflow has never once posted a comment. Every run was green, because a 403 on the POST only raises a ::warning::, and nobody reads a warning on a green run. pull_request_target: closed is the obvious trigger and cannot work here. A run triggered by a fork's pull request gets a read-only GITHUB_TOKEN whatever the repository's Workflow permissions say — setting that to write, which was done yesterday, does not reach it. Granting it means enabling "send write tokens to workflows from fork pull requests", which hands a write token to every fork-triggered run in the repository. That is not a trade worth making for a thank-you note. A push to main is not fork-triggered, so its token honours the permissions block. The PR behind the pushed commit comes from repos/:repo/commits/:sha/pulls rather than the commit subject, because squash writes "(#12)", a merge commit writes "Merge pull request #12", and a rebase merge writes neither. Confirmed on the real failure: ashudhanda's first merged PR (#16) counted correctly as 1 and then 403'd on the comment. workflow_dispatch with a pr input is kept so the path can be exercised without waiting for someone's first contribution.
|
Dispatched against #16 as promised. Still 403 — and that rules out the reason given in this PR. A
The organisation's Workflow permissions setting is still "Read repository contents and packages permissions", and a repository cannot exceed it. Setting the repository value succeeds and simply has no effect — which is why yesterday's change looked like it had worked. The change here is still right and stays: Unblocking needs one click, at the org rather than the repo: Leave "Allow GitHub Actions to create and approve pull requests" unchecked — nothing here needs it. Re-run this workflow with |
|
Found it, and it was not the org setting — that page is already on "Read and write permissions", and so is every repository. Two wrong diagnoses from me before this one. It was this workflow's own permissions block: permissions:
pull-requests: read # ← the denial
issues: write # ← granted, never consultedThe comment goes through Verified by dispatching against #16 with — and the bot's comment is on the PR. Same fix pushed to One correction to this PR's own description, since it is now on record wrongly. The fork-token claim was never tested. The original The thing that let this sit through several merges is worth naming: a 403 here only raises a |
The workflow has never once posted a comment. Every run was green — a 403 on the POST only raises a
::warning::, and nobody reads a warning on a green run.Caught it live merging #16, @ashudhanda's first contribution here:
The count was right. The POST was not allowed.
Why the setting change didn't reach it
pull_request_target: closedis the obvious trigger and cannot work. A run triggered by a fork's pull request gets a read-onlyGITHUB_TOKENwhatever the repository's Workflow permissions say. Setting those to write — done yesterday, and verifiedwriteon all three repos — does not apply to this event.Granting it means enabling "send write tokens to workflows from fork pull requests", which hands a write token to every fork-triggered run in the repository. Not a trade worth making for a thank-you note.
A push to main is not fork-triggered, so its token honours the
permissions:block.Detail worth keeping
The PR behind the pushed commit comes from
repos/:repo/commits/:sha/pulls, not from parsing the commit subject — squash writes(#12), a merge commit writesMerge pull request #12, and a rebase merge writes neither.workflow_dispatchwith aprinput stays so the path can be exercised without waiting on someone's first contribution. I'll use it to verify against #16 once this lands, and post the result here.