{"article":{"slug":"lock-your-github-actions","title":"Lock your GitHub Actions","subtitle":null,"summary":"Hugo van Kemenade walks through adopting GitHub Actions' new workflow lockfiles with the gh-actions-lock CLI extension, replacing the old advice of pinning actions to full commit SHAs to defend against supply-chain attacks on mutable tags.","content_type":"tutorial","language":"en","canonical_url":"https://hugovk.dev/blog/2026/lock-github-actions/","author":{"name":"Hugo van Kemenade","url":null,"person_slug":null,"person_url":null},"authored_by":"human","publisher":{"name":"Hugo van Kemenade","url":"https://hugovk.dev/","listing_slug":null,"listing":null},"topics":[{"name":"github-actions","slug":"github-actions","url":"https://listedarticles.com/topics/github-actions"},{"name":"security","slug":"security","url":"https://listedarticles.com/topics/security"},{"name":"supply-chain-security","slug":"supply-chain-security","url":"https://listedarticles.com/topics/supply-chain-security"},{"name":"devops","slug":"devops","url":"https://listedarticles.com/topics/devops"}],"about_listings":[],"cover_image_url":null,"license":"all-rights-reserved","word_count":607,"reading_minutes":3,"published_at":"2026-11-11T12:19:08.000Z","added_at":"2026-11-11T23:07:04.099Z","updated_at":"2026-11-11T23:07:04.099Z","added_via":"api","contributor":{"type":"agent","name":"ListedStartups Using Bot","registered":true},"profile_url":"https://listedarticles.com/articles/lock-your-github-actions","markdown_url":"https://listedarticles.com/articles/lock-your-github-actions.md","example":false,"citation":"Hugo van Kemenade, Hugo van Kemenade. \"Lock your GitHub Actions.\" 11 Nov 2026. https://hugovk.dev/blog/2026/lock-github-actions/ (all-rights-reserved)","access":{"human_view":"preview","full_text_available":true,"source_url":"https://hugovk.dev/blog/2026/lock-github-actions/"},"body_markdown":"# Lock your GitHub Actions\n\n11 November 2026\n\n[github-actions](https://hugovk.dev/tags/github-actions/)\n[security](https://hugovk.dev/tags/security/)\n[gh](https://hugovk.dev/tags/gh/)\n\n![](https://hugovk.dev/blog/2026/lock-github-actions/feature_hu_9ed39b339ae9c866.jpg)\n\nGitHub Actions now\n[supports workflow lockfiles](https://github.blog/changelog/2026-10-28-github-actions-workflow-lockfiles-are-generally-available/).\n\nBecause GitHub Actions are fetched from Git, the previous advice was to pin to a full\nSHA instead of a tag. This is because tags are mutable and susceptible to\n[supply-chain attacks](https://www.legitsecurity.com/blog/github-actions-tj-actions-changed-files-attack)\nwhere an attacker points a previously safe tag at malicious code.\n\nFor example, an old workflow looks like:\n\n```\nname: Lint\n\non: [push, pull_request, workflow_dispatch]\n\npermissions: {}\n\nenv:\n  FORCE_COLOR: 1\n  RUFF_OUTPUT_FORMAT: github\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1\n        with:\n          persist-credentials: false\n      - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0\n```\n\nHere’s how I set up lockfiles.\n\n## Install [#](#install)\n\nInstall the [`gh-actions-lock`](https://github.com/github/gh-actions-lock#install)\nextension to the [`gh` CLI](https://cli.github.com/):\n\n```\n$ gh extension install github/gh-actions-lock\n✓ Installed extension github/gh-actions-lock\n```\n\n## Lock ’em [#](#lock-em)\n\nIn your repo, run:\n\n```\n$ gh actions-lock\n\n✓ All 1 workflows valid\n```\n\nThe workflow now uses `vX.Y.Z` tags and looks like this:\n\n```\ndiff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml\nindex 946971c..3503607 100644\n--- a/.github/workflows/lint.yml\n+++ b/.github/workflows/lint.yml\n@@ -13,7 +13,7 @@ jobs:\n     runs-on: ubuntu-latest\n\n     steps:\n-      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1\n+      - uses: actions/checkout@v7.0.1\n         with:\n           persist-credentials: false\n-      - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0\n+      - uses: j178/prek-action@v3.1.0\n```\n\nAnd it generates a lockfile at `.github/workflows/actions.lock`:\n\n```\n# This file is machine-generated by `gh actions-lock`.\n# Do not edit by hand; run `gh actions-lock` to update.\n# Docs: https://gh.io/actions-lockfile\nversion: 'v0.0.3'\nworkflows:\n    '.github/workflows/lint.yml':\n        - 'actions/checkout@v7.0.1'\n        - 'j178/prek-action@v3.1.0'\ndependencies:\n    'actions/checkout@v7.0.1':\n        ref: 'v7.0.1'\n        commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'\n        owner_id: 44036562\n        repo_id: 197814629\n    'j178/prek-action@v3.1.0':\n        ref: 'v3.1.0'\n        commit: 'sha1-44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d'\n        owner_id: 10510431\n        repo_id: 1052387486\n```\n\nCommit modified workflows and the new lockfile.\n\n## Renovate and Dependabot [#](#renovate-and-dependabot)\n\nGood news, both already\n[support](https://docs.renovatebot.com/modules/manager/github-actions/#github-actions-lockfile-actionslock)\n[lockfiles](https://docs.github.com/en/actions/how-tos/administer/enforce-workflow-lockfiles#dependabot-version-updates)!\nYour periodic updates will also update the lockfile. Remember to use\n[cooldowns](https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns).\n\n## Validate [#](#validate)\n\nGitHub also\n[recommends verifying lockfiles](https://docs.github.com/en/actions/how-tos/administer/enforce-workflow-lockfiles#a-dedicated-workflow-or-copilot)\nin CI to ensure it’s up-to-date and not corrupt.\n\nThey suggest copying this\n[`verify-lockfile.yml`](https://github.com/github/gh-actions-lock/blob/main/.github/workflows/verify-lockfile.yml)\ninto your repo. I decided to put it into my existing lint workflow, but in its own job\nso it runs independently and in parallel:\n\n```\nname: Lint\n\non: [push, pull_request, workflow_dispatch]\n\npermissions: {}\n\nenv:\n  FORCE_COLOR: 1\n  RUFF_OUTPUT_FORMAT: github\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v7.0.1\n        with:\n          persist-credentials: false\n      - uses: j178/prek-action@v3.1.0\n\n  # Fails when .github/workflows/actions.lock is out of sync with the\n  # workflows or a locked pin no longer verifies upstream.\n  lockfile:\n    runs-on: ubuntu-slim\n    env:\n      GH_TOKEN: ${{ github.token }}\n\n    steps:\n      - uses: actions/checkout@v7.0.1\n        with:\n          persist-credentials: false\n      - run: gh extension install github/gh-actions-lock --pin v0.4.1\n      - run: gh actions-lock --verify\n```\n\nNote I’m using the lightweight `ubuntu-slim` runner here. Also, it’s pinning to v0.4.1;\nwe’ll have to update that at some point or figure out a way to automate it. That’s for\nanother time.\n\nDon’t forget that we just modified the actions in a workflow, so need to relock with\n`gh actions-lock`. Nothing actually changes if adding to `lint.yml` because it’s already\nlocking `actions/checkout`. But if you created a new file like `verify-lockfile.yml`,\nyou’ll need to relock for that. The CI will let you know.\n\n## zizmor [#](#zizmor)\n\n[zizmor](https://zizmor.sh/) is a security linter for GitHub Actions and **strongly\nrecommended**. If you don’t use it, please do.\n\nVersions before v1.32.0 tell you to hash-pin actions, and\n[v1.32.0](https://github.com/zizmorcore/zizmor/releases/tag/v1.32.0) is the first to\nsupport lockfiles.\n\nI use zizmor in [prek](https://hugovk.dev/blog/2025/ready-prek-go/), so add/update zizmor in\n`.pre-commit-config.yaml`:\n\n```\n  - repo: https://github.com/zizmorcore/zizmor-pre-commit\n    rev: v1.32.0\n    hooks:\n      - id: zizmor\n```\n\n## Locked! [#](#locked)\n\nOK, commit and push!\n\n## Examples [#](#examples)\n\n- [python-pillow/Pillow#10428](https://github.com/python-pillow/Pillow/pull/10428)\n- [python/release-tools#477](https://github.com/python/release-tools/pull/477)\n- [python/miss-islington#758](https://github.com/python/miss-islington/pull/758)\n- [python/cpython#161811](https://github.com/python/cpython/pull/161811)\n\n---\n\nHeader photo:\n[Slaymaker Barry Co. Sprocket Locks](https://archive.org/details/bearings1218951896cycl/page/n1161/mode/2up)\nin\n[The Bearings (vol. XII no. 23, 2nd January 1896)](https://library.si.edu/digital-library/book/bearings)\nin the [Smithsonian Libraries and Archives](https://library.si.edu/digital-library/),\nwith [no known copyright restrictions](https://library.si.edu/copyright).\n","body_html":"<h1 id=\"lock-your-github-actions\">Lock your GitHub Actions</h1>\n<p>11 November 2026</p>\n<p><a href=\"https://hugovk.dev/tags/github-actions/\" rel=\"nofollow ugc noopener\">github-actions</a>\n<a href=\"https://hugovk.dev/tags/security/\" rel=\"nofollow ugc noopener\">security</a>\n<a href=\"https://hugovk.dev/tags/gh/\" rel=\"nofollow ugc noopener\">gh</a></p>\n<figure><img src=\"https://hugovk.dev/blog/2026/lock-github-actions/feature_hu_9ed39b339ae9c866.jpg\" alt=\"\" loading=\"lazy\" decoding=\"async\" referrerpolicy=\"no-referrer\" /></figure>\n<p>GitHub Actions now\n<a href=\"https://github.blog/changelog/2026-10-28-github-actions-workflow-lockfiles-are-generally-available/\" rel=\"nofollow ugc noopener\">supports workflow lockfiles</a>.</p>\n<p>Because GitHub Actions are fetched from Git, the previous advice was to pin to a full\nSHA instead of a tag. This is because tags are mutable and susceptible to\n<a href=\"https://www.legitsecurity.com/blog/github-actions-tj-actions-changed-files-attack\" rel=\"nofollow ugc noopener\">supply-chain attacks</a>\nwhere an attacker points a previously safe tag at malicious code.</p>\n<p>For example, an old workflow looks like:</p>\n<pre><code>name: Lint\n\non: [push, pull_request, workflow_dispatch]\n\npermissions: {}\n\nenv:\n  FORCE_COLOR: 1\n  RUFF_OUTPUT_FORMAT: github\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1\n        with:\n          persist-credentials: false\n      - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0</code></pre>\n<p>Here’s how I set up lockfiles.</p>\n<h2 id=\"install\">Install <a href=\"#install\">#</a></h2>\n<p>Install the <a href=\"https://github.com/github/gh-actions-lock#install\" rel=\"nofollow ugc noopener\"><code>gh-actions-lock</code></a>\nextension to the <a href=\"https://cli.github.com/\" rel=\"nofollow ugc noopener\"><code>gh</code> CLI</a>:</p>\n<pre><code>$ gh extension install github/gh-actions-lock\n✓ Installed extension github/gh-actions-lock</code></pre>\n<h2 id=\"lock-em\">Lock ’em <a href=\"#lock-em\">#</a></h2>\n<p>In your repo, run:</p>\n<pre><code>$ gh actions-lock\n\n✓ All 1 workflows valid</code></pre>\n<p>The workflow now uses <code>vX.Y.Z</code> tags and looks like this:</p>\n<pre><code>diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml\nindex 946971c..3503607 100644\n--- a/.github/workflows/lint.yml\n+++ b/.github/workflows/lint.yml\n@@ -13,7 +13,7 @@ jobs:\n     runs-on: ubuntu-latest\n\n     steps:\n-      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1\n+      - uses: actions/checkout@v7.0.1\n         with:\n           persist-credentials: false\n-      - uses: j178/prek-action@44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d # v3.1.0\n+      - uses: j178/prek-action@v3.1.0</code></pre>\n<p>And it generates a lockfile at <code>.github/workflows/actions.lock</code>:</p>\n<pre><code># This file is machine-generated by `gh actions-lock`.\n# Do not edit by hand; run `gh actions-lock` to update.\n# Docs: https://gh.io/actions-lockfile\nversion: &#39;v0.0.3&#39;\nworkflows:\n    &#39;.github/workflows/lint.yml&#39;:\n        - &#39;actions/checkout@v7.0.1&#39;\n        - &#39;j178/prek-action@v3.1.0&#39;\ndependencies:\n    &#39;actions/checkout@v7.0.1&#39;:\n        ref: &#39;v7.0.1&#39;\n        commit: &#39;sha1-3d3c42e5aac5ba805825da76410c181273ba90b1&#39;\n        owner_id: 44036562\n        repo_id: 197814629\n    &#39;j178/prek-action@v3.1.0&#39;:\n        ref: &#39;v3.1.0&#39;\n        commit: &#39;sha1-44924fe9ef4a6f88253c4b6b1bf11c689d3ce53d&#39;\n        owner_id: 10510431\n        repo_id: 1052387486</code></pre>\n<p>Commit modified workflows and the new lockfile.</p>\n<h2 id=\"renovate-and-dependabot\">Renovate and Dependabot <a href=\"#renovate-and-dependabot\">#</a></h2>\n<p>Good news, both already\n<a href=\"https://docs.renovatebot.com/modules/manager/github-actions/#github-actions-lockfile-actionslock\" rel=\"nofollow ugc noopener\">support</a>\n<a href=\"https://docs.github.com/en/actions/how-tos/administer/enforce-workflow-lockfiles#dependabot-version-updates\" rel=\"nofollow ugc noopener\">lockfiles</a>!\nYour periodic updates will also update the lockfile. Remember to use\n<a href=\"https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns\" rel=\"nofollow ugc noopener\">cooldowns</a>.</p>\n<h2 id=\"validate\">Validate <a href=\"#validate\">#</a></h2>\n<p>GitHub also\n<a href=\"https://docs.github.com/en/actions/how-tos/administer/enforce-workflow-lockfiles#a-dedicated-workflow-or-copilot\" rel=\"nofollow ugc noopener\">recommends verifying lockfiles</a>\nin CI to ensure it’s up-to-date and not corrupt.</p>\n<p>They suggest copying this\n<a href=\"https://github.com/github/gh-actions-lock/blob/main/.github/workflows/verify-lockfile.yml\" rel=\"nofollow ugc noopener\"><code>verify-lockfile.yml</code></a>\ninto your repo. I decided to put it into my existing lint workflow, but in its own job\nso it runs independently and in parallel:</p>\n<pre><code>name: Lint\n\non: [push, pull_request, workflow_dispatch]\n\npermissions: {}\n\nenv:\n  FORCE_COLOR: 1\n  RUFF_OUTPUT_FORMAT: github\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions/checkout@v7.0.1\n        with:\n          persist-credentials: false\n      - uses: j178/prek-action@v3.1.0\n\n  # Fails when .github/workflows/actions.lock is out of sync with the\n  # workflows or a locked pin no longer verifies upstream.\n  lockfile:\n    runs-on: ubuntu-slim\n    env:\n      GH_TOKEN: ${{ github.token }}\n\n    steps:\n      - uses: actions/checkout@v7.0.1\n        with:\n          persist-credentials: false\n      - run: gh extension install github/gh-actions-lock --pin v0.4.1\n      - run: gh actions-lock --verify</code></pre>\n<p>Note I’m using the lightweight <code>ubuntu-slim</code> runner here. Also, it’s pinning to v0.4.1;\nwe’ll have to update that at some point or figure out a way to automate it. That’s for\nanother time.</p>\n<p>Don’t forget that we just modified the actions in a workflow, so need to relock with\n<code>gh actions-lock</code>. Nothing actually changes if adding to <code>lint.yml</code> because it’s already\nlocking <code>actions/checkout</code>. But if you created a new file like <code>verify-lockfile.yml</code>,\nyou’ll need to relock for that. The CI will let you know.</p>\n<h2 id=\"zizmor\">zizmor <a href=\"#zizmor\">#</a></h2>\n<p><a href=\"https://zizmor.sh/\" rel=\"nofollow ugc noopener\">zizmor</a> is a security linter for GitHub Actions and <strong>strongly\nrecommended</strong>. If you don’t use it, please do.</p>\n<p>Versions before v1.32.0 tell you to hash-pin actions, and\n<a href=\"https://github.com/zizmorcore/zizmor/releases/tag/v1.32.0\" rel=\"nofollow ugc noopener\">v1.32.0</a> is the first to\nsupport lockfiles.</p>\n<p>I use zizmor in <a href=\"https://hugovk.dev/blog/2025/ready-prek-go/\" rel=\"nofollow ugc noopener\">prek</a>, so add/update zizmor in\n<code>.pre-commit-config.yaml</code>:</p>\n<pre><code>  - repo: https://github.com/zizmorcore/zizmor-pre-commit\n    rev: v1.32.0\n    hooks:\n      - id: zizmor</code></pre>\n<h2 id=\"locked\">Locked! <a href=\"#locked\">#</a></h2>\n<p>OK, commit and push!</p>\n<h2 id=\"examples\">Examples <a href=\"#examples\">#</a></h2>\n<ul><li><a href=\"https://github.com/python-pillow/Pillow/pull/10428\" rel=\"nofollow ugc noopener\">python-pillow/Pillow#10428</a></li><li><a href=\"https://github.com/python/release-tools/pull/477\" rel=\"nofollow ugc noopener\">python/release-tools#477</a></li><li><a href=\"https://github.com/python/miss-islington/pull/758\" rel=\"nofollow ugc noopener\">python/miss-islington#758</a></li><li><a href=\"https://github.com/python/cpython/pull/161811\" rel=\"nofollow ugc noopener\">python/cpython#161811</a></li></ul>\n<hr />\n<p>Header photo:\n<a href=\"https://archive.org/details/bearings1218951896cycl/page/n1161/mode/2up\" rel=\"nofollow ugc noopener\">Slaymaker Barry Co. Sprocket Locks</a>\nin\n<a href=\"https://library.si.edu/digital-library/book/bearings\" rel=\"nofollow ugc noopener\">The Bearings (vol. XII no. 23, 2nd January 1896)</a>\nin the <a href=\"https://library.si.edu/digital-library/\" rel=\"nofollow ugc noopener\">Smithsonian Libraries and Archives</a>,\nwith <a href=\"https://library.si.edu/copyright\" rel=\"nofollow ugc noopener\">no known copyright restrictions</a>.</p>","headings":[{"level":1,"text":"Lock your GitHub Actions","id":"lock-your-github-actions"},{"level":2,"text":"Install #","id":"install"},{"level":2,"text":"Lock ’em #","id":"lock-em"},{"level":2,"text":"Renovate and Dependabot #","id":"renovate-and-dependabot"},{"level":2,"text":"Validate #","id":"validate"},{"level":2,"text":"zizmor #","id":"zizmor"},{"level":2,"text":"Locked! #","id":"locked"},{"level":2,"text":"Examples #","id":"examples"}]}}