Sub topic 6
Updating pinned actions with Dependabot
This chapter assumes you can read a GitHub Actions workflow, know the difference between a tag and a commit, and have pinned at least one action to a full-length commit SHA. Pinning makes a workflow reproducible. It also freezes it: nothing updates the pin when the action's author ships a security fix. Dependabot closes that gap.
Why pins go stale
A SHA pin names one commit forever. If actions/checkout publishes a new release, your workflow keeps running the old commit. Without a process, pins drift behind and you miss fixes. Teams then either stop pinning or never update, and both defeat the purpose.
Dependabot is GitHub's dependency update bot. For GitHub Actions it reads the uses: references in your workflows, checks for newer releases, and opens a pull request that changes the reference. You review and merge it like any other change.
Enabling the github-actions ecosystem
Create .github/dependabot.yml in the default branch:
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"The directory: "/" value is special for this ecosystem. Dependabot scans .github/workflows/ and also looks for action.yml files at the repository root. For local composite actions in other folders, add a separate entry whose directory points at that folder.
What an update pull request looks like
When Dependabot finds a newer release, it rewrites the SHA and, if a version comment is present, the comment as well:
steps:
# Before
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# After the pull request is merged: new SHA, new comment
- uses: actions/checkout@<new-full-length-sha> # v4.3.0The comment matters here. Dependabot uses the trailing version comment to understand which release the SHA stands for. Keep it in the form # vX.Y.Z on the same line as the uses: key. The pull request description lists the release notes and commits between the two versions, which is what you review.
Reviewing the pull request
Dependabot automates the bump, not the trust decision. A pinned action that you update blindly gives you reproducibility without protection. Before merging, check:
- The release notes describe a change you expect.
- The diff between the two commits is small enough to skim, or comes from an author you trust.
- CI passes on the pull request branch.
Tuning the noise
Weekly pull requests for every action can pile up. Two options help:
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
open-pull-requests-limit: 5The groups block combines all action updates into one pull request. This reduces review overhead, but a grouped pull request is harder to bisect if one update breaks a job. Use update-types inside a group if you want minor and patch updates grouped while major versions stay separate.
Common errors
- No pull requests appear. Check that the file is at
.github/dependabot.ymlon the default branch and that the ecosystem name is spelledgithub-actions, with a hyphen. - The comment does not update. The comment was missing or not on the same line as
uses:. Fix it by hand once, and later updates follow. - Updates to a tag-pinned action still appear. This is expected. Dependabot also updates
@v4style references, so SHA pins are not required for it to work. - Transitive references are untouched. Dependabot edits what your files contain. It does not rewrite the inner references of a third-party composite action. The next chapters cover that gap.
Exercise
Your Dependabot configuration is in place, but a pull request for a SHA-pinned action changed the SHA and left the old version comment. What is the likely cause, and how do you fix it?
Show answer
The comment was probably not in the expected form (# vX.Y.Z on the same line as the uses: key), so Dependabot could not tie it to the release. Correct the comment by hand so it matches the pinned version and keep it on the same line. Later updates will then change the SHA and the comment together.