Skip to content

Pin GitHub Actions to commit SHAs - #285

Open
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:ci/pin-actions-to-shas
Open

Pin GitHub Actions to commit SHAs#285
tas50 wants to merge 1 commit into
chef:mainfrom
tas50:ci/pin-actions-to-shas

Conversation

@tas50

@tas50 tas50 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Every third-party action in this repo's workflows is referenced by a mutable pointer. This converts them all to immutable commit SHAs, with the version preserved in a trailing comment.

Why

A tag is a movable pointer. Anyone who can push to an action's repository can repoint @v1 at new code, and every workflow referencing it picks that up on the next run with no change on our side. A commit SHA can't be repointed.

Three references here weren't even pinned to a version — they floated on a branch head, so every run picks up whatever happened to land on that branch:

actionshub/dco@main
actionshub/get-pr-commits@main
fernandrone/linelint@master

Those two actionshub actions gate DCO sign-off on every PR to this repo.

The pins

Action Was Now
actions/checkout @v6 d23441a # v6.1.0
ruby/setup-ruby @v1 95ef2b0 # v1.321.0
r7kamura/rubocop-problem-matchers-action @v1 59f1a07 # v1.2.2
streetsidesoftware/cspell-action @v8.4.0 de2a73e # v8.4.0
wechuli/allcheckspassed @v1 e22f45a # v1.2.0
actionshub/dco @main 6246515 # v2.0.0
actionshub/get-pr-commits @main 0f1d778 # v2.0.0
fernandrone/linelint @master 7907a5d # 0.0.6

This is a conversion, not an upgrade. Each pin resolves to the newest release within the major version already in use, so behavior is unchanged — checkout stays on v6 rather than jumping to v7, and cspell-action stays on the exact v8.4.0 it already named rather than moving to v9. The @main and @master refs are the one place a version genuinely changes, because there was no version to preserve; those resolve to the latest tagged release, since an untagged commit gives Dependabot nothing to track.

Dependabot

SHA pins never move on their own, so pinning without automated bumping just trades a supply-chain risk for a staleness one. This repo had no dependabot.yml at all, so this adds one covering both github-actions and bundler — neither was being tracked. Dependabot reads the trailing # vX.Y.Z comment to determine the current version and rewrites both the SHA and the comment on each bump.

Left alone

ci-main-pull-request-stub-1.0.7.yml references chef/common-github-actions/.github/workflows/ci-main-pull-request.yml@main — a reusable workflow from an internal repo, not a third-party action. Pinning it would cut this repo off from centrally-managed CI updates, which is the opposite of what that stub is for.

Verification

All four workflow files and the new dependabot.yml parse as valid YAML. Every uses: reference outside the stub now resolves to a 40-character commit SHA — verified by grepping for any ref that isn't one, which returns nothing.

Worth raising separately

This repo has no unit-test workflow. lint.yml, dco.yml, and allchecks.yml are the whole of CI; the stub sets unit-tests: false. The gemspec declares required_ruby_version = ">= 3.1" and spec/ is well populated with rake spec wired up, but nothing runs it on any Ruby. That's a bigger change than pinning and I've deliberately kept it out of this PR — happy to open one adding a matrix over 3.1 through 4.0 if you want it.

Tags and branch refs are mutable pointers. Anyone who can push to an action's
repository can repoint `@v1` — or `@main` — at new code, and every workflow
referencing it picks that up on the next run with no change on our side. A
commit SHA cannot be repointed.

Three references here floated on a branch head rather than any version at all:

    actionshub/dco@main
    actionshub/get-pr-commits@main
    fernandrone/linelint@master

Each pin keeps the version in a trailing `# vX.Y.Z` comment, which is what
Dependabot reads to bump it later. Pins stay inside the major version already
in use, so this is a conversion rather than an upgrade; the `@main` and
`@master` refs move to the latest tagged release, since an untagged commit
gives Dependabot nothing to track.

Also adds a dependabot.yml. There was none, so nothing would ever bump the new
SHA pins, and no bundler updates were being tracked either.

ci-main-pull-request-stub-1.0.7.yml is deliberately untouched. It references a
reusable workflow in chef/common-github-actions, not a third-party action, and
pinning it would cut this repo off from centrally-managed CI updates.

Signed-off-by: Tim Smith <tsmith84@proton.me>
@tas50
tas50 requested review from a team and jaymzh as code owners August 28, 2026 16:19
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