fix(github): fall back to the workflow token when the optional secret is absent - #50
Merged
Merged
Conversation
… is absent Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes token handling in two reusable GitHub Actions workflows so that an optional token secret behaves correctly: when the caller does not provide it, the workflows fall back to the workflow run’s default token (github.token) instead of passing an empty value or ignoring the declared interface.
Changes:
- Update
stale.ymlto usesecrets.token || github.tokenforactions/stale’srepo-token, preventing empty-string override behavior. - Update
labeler.ymlto use the declaredtokensecret (with the same fallback), aligning the workflow’s published interface with its implementation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| .github/workflows/stale.yml | Uses `secrets.token |
| .github/workflows/labeler.yml | Reads the declared token secret (with fallback) instead of ignoring it in favor of secrets.GITHUB_TOKEN. |
NorthernMan54
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two reusable workflows mishandle their optional
tokensecret. Split out of #48, where @copilot spotted both — that PR is a version bump across 21 workflows, and token handling affects every repository in the org, so it deserves reviewing on its own terms.Neither is introduced by #48; both predate it.
stale.ymlThe secret is declared optional but passed unconditionally. A caller that omits it sends an empty string, which overrides the action's own default rather than falling back to it, and the run fails to authenticate. Callers that do pass a token have never seen this — which is why it has gone unnoticed.
labeler.ymlDeclares a
tokensecret that nothing reads. A caller can pass one and it is silently ignored. It works today only because it happens to readGITHUB_TOKENdirectly, so the published interface is misleading rather than broken.The fix
Both now read the declared secret with a fallback to the workflow's own token:
Backwards compatible in both directions: a caller passing
tokengets what it passed, and one that does not gets the default it was already relying on.Audit of the rest
I checked every workflow in the repo that declares a
tokensecret, rather than assuming these were the only two:requiredstale.ymlsecrets.tokenlabeler.ymlsecrets.GITHUB_TOKENpr-labeler.ymlsecrets.tokenrelease-drafter.ymlsecrets.tokennodejs-build-and-test.ymlsecrets.github_tokenandsecrets.tokennodejs-build-and-test.ymlhas a third, milder instance. Its two Coveralls steps disagree:Coveralls Parallelreadssecrets.github_tokenwhileCoveralls Finishedreadssecrets.token. Only one of those is the declared secret. It is inert unlessenable_coverageis on, so nothing is broken today.I have deliberately left it out of this PR because #49 already modifies that file and the two would conflict. Happy to follow up once #49 lands, or fold it in here if you would rather see it merged first.