Skip to content

Pin workflow actions to commits and grant their tokens only what they need - #3088

Merged
ericproulx merged 1 commit into
masterfrom
chore/pin-workflows-read-only-tokens
Nov 20, 2026
Merged

ericproulx merged 1 commit into
masterfrom
chore/pin-workflows-read-only-tokens

Conversation

@ericproulx

@ericproulx ericproulx commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

While reviewing #3077 and #3078 I asked for their reusable workflows to be pinned by SHA, but none of our own workflows were. All 12 action and reusable-workflow references used a tag or branch their owner can move. Every job also ran with the repository's default token, which is read/write, since no workflow declared permissions:.

Pins

Each reference now names the commit its tag or branch points to today, with the version as a comment, so nothing that runs changes:

Reference Was Pinned to
actions/checkout @v6 d23441a4… # v6.1.0
ruby/setup-ruby @v1 (a branch) be3c7df2… # v1.343.0
coverallsapp/github-action @v2 8d6379e1… # v2.3.8
numbata/danger-pr-comment danger-run.yml @v0.2.0 6152b443… # v0.2.0
numbata/danger-pr-comment danger-comment.yml @v0.1.0 34fd3761… # v0.1.0

Tokens and secrets

  • test.yml and edge.yml declare permissions: contents: read. Coveralls only needs the token to identify the repository: it posts no status or comment on master or on PRs.
  • Both Danger callers drop secrets: inherit. It handed every repository secret to the called workflow, though Danger's workflows only use secrets.GITHUB_TOKEN || github.token. Each caller now grants exactly what its called workflow declares: contents: read for the run, and contents: read, actions: read, issues: write, pull-requests: write for the comment.

Dependabot

.github/dependabot.yml updates the pinned actions and reusable workflows weekly, grouped into one PR, with their version comments. cooldown: default-days: 7 means a release is proposed only once it's a week old, so a compromised one has time to be caught.

Validation

test.yml and danger.yml run on this PR with these changes. Danger Comment runs on workflow_run from master's copy, so its new caller only takes effect after merge.

🤖 Generated with Claude Code

… need

Every action and reusable workflow was referenced by a tag or a branch its
owner can move, and every job ran with the repository's default read/write
token. Both Danger callers also passed `secrets: inherit`, handing every
repository secret to another repository's workflow, though Danger uses only
the token.

Each reference now names the commit its tag or branch points to today, with
the version as a comment, so what runs is unchanged. test and edge read only.
The Danger callers grant what the called workflows ask for, and no secrets.
Dependabot keeps the pins current, proposing a release once it is a week old.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@ericproulx
ericproulx merged commit b385782 into master Nov 20, 2026
52 checks passed
@ericproulx
ericproulx deleted the chore/pin-workflows-read-only-tokens branch November 20, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant