Trying out GitHub Actions workflow lockfiles: pinning dependencies to commits with actions.lock, and stopping before execution if they drift

Trying out GitHub Actions workflow lockfiles: pinning dependencies to commits with actions.lock, and stopping before execution if they drift

I tried the GitHub Actions workflow lockfile: gh actions-lock generates actions.lock, records transitive dependencies, halts runs when not updated, and keeps pinned commits even if tags move. Updated for GA and v0.4.0.
2026.10.16

This page has been translated by machine translation. View original

Hello! I'm Yuji Nishimura from the Ops Team!

In the GitHub documentation and in each action's README, actions used in GitHub Actions are written as tag references such as actions/checkout@v5. However, tags can be moved later, so there is room for code different from what you reviewed to run in CI. One countermeasure is to pin to a full commit SHA, but that makes workflows harder to read. Moreover, it cannot pin other actions that an action calls internally (transitive dependencies).

workflow dependency lockfiles are a mechanism for pinning a workflow's dependencies with a lockfile. Following the same idea as npm and pnpm lockfiles, the commit of each action is recorded in .github/workflows/actions.lock, and at run time the recorded commits are used. It entered public preview on October 14, 2026 and became GA on October 28.

In this article, I'll verify the following three points with a Free plan account.

  • What gh actions-lock generates, and how workflows get rewritten
  • What happens when you add an action without updating the lockfile
  • Which commit is run when the referenced tag moves

The Require lockfile policy and lockfile updates by Dependabot are not covered in this article; they are tried in the articles introduced in the update note. Calls to reusable workflows are outside the scope of the lockfile (see the next section).

Scope and availability

  • Availability: Public preview on October 14, 2026, GA on October 28, 2026
  • Scope: According to the GA changelog, it applies to GitHub Enterprise Cloud, GitHub Enterprise Cloud with data residency, Team, and Free. GitHub Enterprise Server is stated as unsupported in the gh actions-lock README
  • Lockfile location: .github/workflows/actions.lock. It is generated and updated by the GitHub CLI extension gh actions-lock, and is not meant to be edited by hand
  • What is recorded: The commits of directly referenced actions and transitive dependencies (details in the next section). According to the documentation, calls to reusable workflows (jobs.<job_id>.uses) are not pinned, so if you want to pin them, reference them with a full commit SHA
  • Onboarding is per workflow: Putting a workflow under lockfile management is called onboarding. An onboarded workflow needs a lockfile entry for every dependency it uses. Actions runs the recorded commits
  • Related features: Dependabot also updates the corresponding lockfile entries in action version update PRs. There is also a Require lockfile policy that makes lockfiles mandatory

What does actions.lock record, and how does it differ from SHA pinning?

According to the official documentation, the lockfile has two sections: workflows and dependencies. workflows is the list of dependencies used by each onboarded workflow, and dependencies is the resolution result for each reference. The following items are recorded for each dependency.

Item Content
ref The tag or branch the workflow references
commit The commit SHA that the reference resolved to
owner_id The numeric ID of the owner of the referenced repository
repo_id The numeric ID of the referenced repository. GitHub Actions checks it together with owner_id at run time

For a dependency that has transitive dependencies, the list of dependencies it calls is also attached as uses:.

There are two differences from SHA pinning. One is that transitive dependencies are pinned too. Actions that a composite action uses: internally are also included in dependencies, and the parent-child relationships are recorded. The other is that repository identifiers are kept. The official documentation says that at run time GitHub Actions uses owner_id and repo_id to check that the repository behind the name is the same as when it was pinned. The official documentation states that SHA pinning inside workflows becomes unnecessary in repositories that use a lockfile.

Trying it out

Environment

  • October 16, 2026: macOS 26.6.1, GitHub CLI 2.101.0, gh actions-lock v0.2.0. Verified through to GitHub Actions runs in a test repository created on a Free plan account (the test repository has since been deleted)
  • November 2, 2026: macOS 26.7.2, GitHub CLI 2.103.2, gh actions-lock v0.4.0 (the latest as of November 2, 2026). I onboarded the same setup again in a local folder and checked the output and rewrites of gh actions-lock. The run page is from the test repository used for another article on the same day

The extension can be installed with the following commands. If it is already installed, update it with gh extension upgrade actions-lock.

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

1. The workflow before adoption

As a starting point for comparison, I prepared a workflow that uses three tag-referenced actions and one local composite action. aquasecurity/trivy-action is a composite action that calls other actions internally, so I use it to check transitive dependencies.

.github/workflows/ci.yml
name: ci
on:
  push:
    branches: [main]
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: actions/setup-node@v5
        with:
          node-version: 24
      - run: node --version
      - uses: ./.github/actions/hello
      - uses: aquasecurity/trivy-action@v0.36.0
        with:
          scan-type: fs
          scan-ref: .
          exit-code: 0

When I pushed in this state on October 16, 2026, the run succeeded, and the "Set up job" log showed the results of resolving the tags. Two lines for actions/cache and actions/checkout, which setup-trivy calls further, are omitted.

Download action repository 'actions/checkout@v5' (SHA:fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09)
Download action repository 'actions/setup-node@v5' (SHA:a0853c24544627f65ddf259abe73b1d18a591444)
Download action repository 'aquasecurity/trivy-action@v0.36.0' (SHA:ed142fd0673e97e23eac54620cfb913e5ce36c25)
Download action repository 'aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514' (SHA:3fb12ec12f41e471780db15c232d5dd185dcb514)
Download action repository 'actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae' (SHA:27d5ce7f107fe9357f9df03efb73ab90386fccae)

setup-trivy and actions/cache are fetched inside trivy-action. These are transitive dependencies not written in the workflow, and including those of setup-trivy there are four.

2. Generating the lockfile

Running it at the repository root with no arguments scans all workflows under .github/workflows/.

gh actions-lock

The following is the output in v0.4.0. The red frame is an addition.

Output of gh actions-lock v0.4.0. The warning "Cannot follow 1 workspace-local action" at the top is enclosed in a red frame, followed by a message showing that 3 direct dependencies and 4 transitive dependencies were pinned

In addition to the 3 direct dependencies, 4 transitive dependencies (setup-trivy and actions/cache from trivy-action, and actions/cache and actions/checkout from setup-trivy) were pinned. This is the same as in v0.2.0. The changes are not limited to adding the lockfile; they also go into the workflow itself. After generation, check the workflow diff as well before committing.

.github/workflows/ci.yml
-      - uses: actions/checkout@v5
-      - uses: actions/setup-node@v5
+      - uses: actions/checkout@v5.1.0
+      - uses: actions/setup-node@v5.0.0
         with:
           node-version: 24
       - run: node --version
       - uses: ./.github/actions/hello
       - uses: aquasecurity/trivy-action@v0.36.0

References with only a major version, such as @v5, are rewritten to the full tag (@v5.1.0) that points to the resolved commit. According to the explanation in gh actions-lock --help, full version tags rarely move after release, so the aim is to lengthen the period during which the pinned SHA stays valid. References that are already full tags from the start, such as @v0.36.0, are left as they are. You can disable this with --no-narrow.

On the other hand, the local action ./.github/actions/hello was not rewritten, and a warning "Cannot follow 1 workspace-local action" appeared at the top of the output. In v0.2.0 on October 16, 2026, this was automatically rewritten to $/.github/actions/hello. The release notes for v0.3.0 say that ./ actions are no longer followed, and the documentation also says they are rewritten only when --migrate-local-actions is added. Also, if there is a ./ action that uses remote actions, it stops with an error by default (this can be turned into a warning with --ignore-local-actions).

When I ran it with --migrate-local-actions, it was rewritten to $/, as in v0.2.0.

gh actions-lock --migrate-local-actions
.github/workflows/ci.yml
-      - uses: ./.github/actions/hello
+      - uses: $/.github/actions/hello

$/ is a reference to "the running commit of the same repository as this workflow" and always resolves to the running SHA, so it needs no lockfile entry. The documentation says that for a ./ action that uses no other actions (one with only run:, like hello here), the workflow works as is even if left as ./. I haven't tried running it with ./ left as is. Since rewriting with --migrate-local-actions is the recommended approach, it seems best to rewrite it when the warning appears.

The generated actions.lock is as follows. The three entries for actions/setup-node@v5.0.0 and for actions/cache and actions/checkout under setup-trivy are omitted. The recorded commits and the structure were the same in v0.2.0 and v0.4.0.

.github/workflows/actions.lock
# This file is machine-generated by `gh actions-lock`.
# Do not edit by hand; run `gh actions-lock` to update.
# Docs: https://gh.io/actions-lockfile
version: 'v0.0.3'
workflows:
    '.github/workflows/ci.yml':
        - 'actions/checkout@v5.1.0'
        - 'actions/setup-node@v5.0.0'
        - 'aquasecurity/trivy-action@v0.36.0'
dependencies:
    'actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae':
        ref: 'v5.0.5'
        commit: 'sha1-27d5ce7f107fe9357f9df03efb73ab90386fccae'
        owner_id: 44036562
        repo_id: 215566462
    'actions/checkout@v5.1.0':
        ref: 'v5.1.0'
        commit: 'sha1-fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09'
        owner_id: 44036562
        repo_id: 197814629
    'aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514':
        ref: 'v0.2.6'
        commit: 'sha1-3fb12ec12f41e471780db15c232d5dd185dcb514'
        owner_id: 12783832
        repo_id: 869952525
        uses:
            - 'actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb'
            - 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8'
    'aquasecurity/trivy-action@v0.36.0':
        ref: 'v0.36.0'
        commit: 'sha1-ed142fd0673e97e23eac54620cfb913e5ce36c25'
        owner_id: 12783832
        repo_id: 268833180
        uses:
            - 'actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae'
            - 'aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514'

The trivy-action entry lists setup-trivy and actions/cache as uses:, and the setup-trivy entry continues with its own dependencies. Even though transitive dependencies are referenced by SHA, the original tag name such as v5.0.5 remains in ref, so you can trace which versions are in use from the lockfile alone.

When I committed and pushed these changes on October 16, 2026, the run succeeded. In the "Set up job" fetch log, the SHAs were the same as before adoption, apart from the tag names changing, as in actions/checkout@v5.1.0. The local action changed to $/ was fetched as <owner>/<repo>@<running commit>.

3. Adding an action without updating the lockfile

On October 16, 2026, in the onboarded workflow, I added an actions/cache@v4 step without updating the lockfile and pushed.

.github/workflows/ci.yml
      - run: node --version
      - uses: actions/cache@v4
        with:
          path: ~/.npm
          key: npm-${{ runner.os }}

The result was a startup_failure in which no job started. Below is the run page from November 2, 2026, in the test repository of another article, where actions/cache@v4 was likewise added without putting it in the lockfile. The red frame is an addition.

Run page where actions/cache@v4 was added without updating the lockfile. Status is Startup failure, and Annotations show "Invalid lockfile: .github/workflows/actions.lock#L1" and "The lockfile is missing . Regenerate it by running .", both enclosed in red frames

The annotation names the reference missing from the lockfile (actions/cache@v4) and directs you to regenerate with gh actions-lock. On October 16, 2026, the message was "The lockfile could not be validated." and did not show the missing reference. In either case, a workflow containing an action that was forgotten to be pinned stops before any job starts.

The same state can also be detected locally. --verify is a mode that checks without rewriting anything.

gh actions-lock --verify

Output of gh actions-lock --verify v0.4.0. Following "1 of 1 workflow failed", it fails because actions/cache@v4 is not pinned in the lockfile

Following "Not pinned actions/cache@v4", it reports that the reference is used in the workflow but not pinned in the lockfile. --verify-local, which does not use the network, also failed with "1 of 1 workflow failed: 1 not-pinned". This one only checks whether each reference has an entry, so you need --verify to confirm that the contents of the entries are correct.

The fix is simply to rerun it with the workflow specified.

gh actions-lock .github/workflows/ci.yml
gh actions-lock --verify

With v0.4.0 as well, actions/cache@v4 was rewritten to @v4.3.0, one entry was added to the lockfile, and --verify reported "All 1 workflow valid". The run pushed on October 16, 2026 also succeeded, and the fetch log showed actions/cache@v4.3.0 (SHA:0057852b...).

4. When the referenced tag moves

This section is the result of testing with v0.2.0 on October 16, 2026. Because the test repository was deleted, I have not re-verified it with v0.4.0.

The real purpose of the lockfile is to "run the pinned commit even if the tag moves." Since you cannot move tags in someone else's repository, I added a step that remotely references the test repository's own composite action in the form owner/repo/path@v1, and moved the tag v1 myself.

.github/workflows/ci.yml
      - uses: <owner>/<repo>/.github/actions/hello@v1

The steps were as follows.

  1. Create the tag v1, add the uses: above to the workflow, and lock it with gh actions-lock. The commit in the lockfile is 607ea0a
  2. Push a different commit, and move v1 to that commit (24c8add) with git push -f
  3. Run the workflow with workflow_dispatch without updating the lockfile

The run log looked like this (the repository name is hidden).

Download action repository '<owner>/<repo>@v1' (SHA:607ea0a6f16c076321a582ebb583afa0d3eac3ee)

The remote v1 points to 24c8add, but what ran was 607ea0a, recorded in the lockfile. Merely moving the tag does not change what runs.

At this point, both gh actions-lock --verify and gh actions-lock with no arguments locally reported "All 1 workflow valid", and the file did not change. As stated in the release notes for v0.2.0, already pinned pins are "sticky" and are not re-resolved by a normal gh actions-lock run. According to the current documentation, handling differs by the type of reference. For branches or partial versions such as main or v3, the pinned commit is kept and a ref-moved warning is shown. If a full version tag such as v3.1.0 moves, it becomes an error, and either --relock or a change to uses: is needed. The v1 here corresponds to the former, but I have not verified it with v0.4.0.

If you want to follow the new commit, use --relock.

gh actions-lock --relock

A diff appeared in which the lockfile's commit changed from 607ea0a to 24c8add. If the pinned commit has disappeared from the reference's history, for example due to a force push, --relock will not fix it. The documentation says to check the upstream history and then run gh actions-lock --accept-moved, and not to use it in automation. I have not tried that situation.

Key points when building it into operations

From what I measured and the official documentation, the shape of operations seems to be as follows. The results of actually combining CI, Dependabot, and Require lockfile are summarized in the article that tried post-GA operations.

  • Verify the lockfile in PRs: Put a job that runs gh actions-lock --verify in PRs and fail it if the lockfile is outdated. The gh actions-lock repository has an official sample verify-lockfile.yml, but as of November 2, 2026 it pins gh actions-lock to v0.2.0, so it seems best to bump the version before using it
  • Review lockfile diffs: A change in commit means different code will run, so review it the same way as a dependency version update. A change in owner_id or repo_id means the repository was replaced, so investigate before merging
  • Update timing: Rerun gh actions-lock when you add or remove a uses:. Use --relock when you want to follow a tag move. Dependabot also updates the corresponding lockfile entries in version update PRs for onboarded workflows. It does not onboard new workflows, so you run that yourself
  • Making the lockfile mandatory: With "Require lockfile" under "Settings" → "Actions" → "Policies", you can block runs of workflows that have not been onboarded. According to the documentation, it is available for public repositories and for private repositories on GitHub Team or GitHub Enterprise. "Evaluate", which only records the results, is available only on GitHub Enterprise Cloud

Notes on adoption

  • The extension is still 0.x: The lockfile itself has gone GA, but gh actions-lock is at v0.4.0 as of November 2, 2026. In v0.3.0, the handling of local actions and the --verify judgment changed. A lockfile created with v0.2.0 may become incomplete-lockfile under --verify, in which case recreate it with gh actions-lock --relock. It also now refuses to pin a reference written with a full SHA to a commit that exists only in a fork (an impostor commit)
  • Compatibility with allowlists: According to the official documentation, after onboarding, the allowlist (Allow select actions) is matched against the pinned commit SHA, so allow entries written with tags such as actions/checkout@v5 no longer match. It says they need to be changed to wildcards or full commit SHAs. I have not tried this time
  • Handling of local actions: In v0.4.0, ./ actions are not rewritten and a warning is shown. To rewrite to $/, add --migrate-local-actions. If there is a ./ action that uses remote actions, it stops with an error by default
  • Nothing is written if there are errors: According to the v0.3.0 release notes, a lockfile that would not pass its own --verify is not written. The v0.2.0 README explained that if even one reference cannot be resolved, nothing is written, including for other workflows. When the referenced tag or commit does not exist, you need to fix the workflow first

Summary

The GitHub Actions workflow lockfile was a mechanism that generates .github/workflows/actions.lock with gh actions-lock and records the commits and repository IDs of direct and transitive dependencies. If an onboarded workflow uses an action that is not in the lockfile, it stops with startup_failure before any job starts, and the same state can be detected locally with --verify. Even if the referenced tag moves, the pinned commit is still what runs, and you update with --relock only when you want to follow it.

Even now that it is GA, the behavior of gh actions-lock changes with versions. In v0.4.0, --migrate-local-actions is required to rewrite local actions to $/. For lockfiles created around v0.2.0, it seems best to check them with --verify and recreate them with --relock if necessary. If you are managing SHA pinning by hand, replacing it with a lockfile is worthwhile, since it can pin even transitive dependencies and lets workflows stay readable with tag names.

Reference links:

Share this article