GitHub Actions Lockfiles: Keep Readable Tags, Run Reviewed Commits


A GitHub Actions workflow often looks reassuringly specific: uses: actions/checkout@v4. Yet v4 is a Git tag, and a tag is a name that can be moved. If the target changes between review and execution, the workflow can run code that nobody reviewed in your repository. Pinning every action to a full commit SHA has long solved that particular problem, but a page of opaque hashes is harder to maintain and review.

GitHub’s workflow dependency lockfiles offer another path. The workflow keeps a recognizable version reference; .github/workflows/actions.lock records the exact commit that GitHub will execute. The important change is where the trusted identity lives: in a generated, reviewable file committed alongside the workflow. The feature became generally available in October 2026, and Hugo van Kemenade’s walkthrough shows how to migrate a real lint workflow.

Why a version tag is not a pin

A normal action reference is resolved when the job runs. If a workflow says owner/action@v3, the runner ordinarily receives the commit pointed to by v3 at that time. A repository compromise, a mistaken retag, or an intentionally moving branch can change that target without touching your workflow file. Reviewing only the workflow diff would miss the change.

A full SHA in every uses: line fixes the resolution point. It also separates the useful version label from the executable identity: teams often add a comment like # v3.1.0 next to the hash, then must keep the comment and hash aligned. A lockfile keeps both pieces of information in one managed dependency record. GitHub says an onboarded workflow runs the recorded commit even when its tag or branch moves.

A workflow version tag is resolved through actions.lock to a recorded commit, which is what the runner executes.
The workflow remains readable while the lockfile controls the code that runs.

What the lockfile contains

The generated file lives at .github/workflows/actions.lock. Its workflows section associates an onboarded workflow with the actions it uses. Its dependencies section records each reference, its commit, and repository identity fields. It also covers actions used by those actions, so a composite action cannot quietly pull in an unlocked remote action. GitHub validates that a locked commit remains reachable from the recorded ref in the original action repository.

A simplified entry looks like this:

workflows:
  '.github/workflows/lint.yml':
    - 'actions/checkout@v7.0.1'
dependencies:
  'actions/checkout@v7.0.1':
    ref: 'v7.0.1'
    commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
    owner_id: 44036562
    repo_id: 197814629

The IDs matter because a familiar repository name can be reused after deletion or transfer. Treat the file as generated output. Review its changes, but regenerate it with the CLI instead of editing it by hand. The exact version and commit above are an illustration from the original walkthrough; choose and verify the current versions for your own repository.

Onboard a repository

Start by examining every uses: reference and deciding whether the action and version are ones you want to trust. A lockfile makes the current choice durable; it does not decide whether that choice is safe. Then install the GitHub CLI extension and run it in the repository:

gh extension install github/gh-actions-lock
gh actions-lock

The extension writes actions.lock and may rewrite workflow references to version tags. Inspect both changes before committing them. In the example walkthrough, a lint job moves from SHA references with version comments to actions/checkout@v7.0.1 and j178/prek-action@v3.1.0; the generated file carries their commits. GitHub supports onboarding workflows gradually, but every dependency of a workflow you have onboarded must be represented in the lockfile.

Run the command again whenever you add a workflow or change a uses: reference. A new verification workflow may itself use an action, which means it also needs to be locked. If you use local ./... actions that themselves call remote actions, consult the extension’s migration options; ordinary local references are not followed automatically.

Make stale locks fail before merge

The lockfile is useful only if changes to a workflow and its locked dependencies stay in sync. GitHub recommends a CI check using:

gh actions-lock --verify

This mode checks the lockfile without rewriting it. A lightweight job can check out the repository, install a pinned version of the extension, and run that command on pull requests. Van Kemenade places such a job beside the existing lint job so both run independently. Pin the extension version in CI and review extension upgrades, since the verifier is part of the trust path.

Dependabot can regenerate matching lockfile entries when it updates actions in an already onboarded workflow. That keeps routine version bumps in one pull request; it does not onboard brand-new workflows for you. A lockfile diff that changes a commit is a code change to your CI system. Review the upstream release and the commit transition, not merely the version string. A CODEOWNERS rule for actions.lock can route those changes to the people responsible for build security.

Workflow change leads to lockfile regeneration, then CI verification and review of the commit diff.
Keep regeneration and review in the same pull request as the workflow edit.

For larger organizations, GitHub offers a Require lockfile policy. Pilot it on repositories that already have complete coverage before enabling enforcement broadly. An enforced policy can block a targeted workflow without a valid lockfile, including a workflow with no uses: line. The policy and a CI verification job play different roles: policy prevents execution, while the check gives contributors a failure they can resolve before merge.

Boundaries of the protection

A lockfile pins action code, including transitive action dependencies. It does not freeze every input to a build. Runner images, container images, downloaded scripts, package installs, secrets, and action inputs still need their own controls. The extension currently does not lock a reusable workflow called with jobs.<id>.uses; pin that call to a full SHA or ensure the called repository has its own lockfile. A local action also needs special attention if it fetches remote actions.

Nor does a lockfile make a malicious action benign. If you lock an unsafe commit, GitHub will faithfully run that unsafe commit. The key security step remains human review at the moment a dependency is added or its locked commit changes. Full SHA references and lockfiles both establish execution identity; neither replaces narrow permissions, careful secret handling, or scrutiny of untrusted pull requests.

The practical outcome is a cleaner review contract. Workflow authors can express the version they intend to use, while reviewers can see the exact code identity that will run. Regenerate, verify, and inspect the lockfile as part of every workflow change, and a moving tag no longer silently changes an onboarded job.

Sources

100%