---
title: "Lock every CI action and its dependencies · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/ci-dependency-lock
id: ENG-55
level: Required
risk: takeover
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1125
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Lock every CI action and its dependencies to a reviewed commit

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

- ID: ENG-55
- Level: Required
- Chapter: [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md)
- Rule: Run every outside CI action, reusable workflow and template at a commit you reviewed, including the actions they call inside. A tag that moves must never change what runs.
- Check: In CI, `gh actions-lock --verify` passes, or a search of the CI files finds 0 `uses:` lines and 0 `include:` entries without a 40-character commit hash. A pull request that changes a `uses:` line without its lock entry fails the check.
- Risk: An account or system taken over
- How: A tag such as `v4` can point at new code tomorrow. A hijacked action then runs with the job's token and secrets. A commit hash in the workflow pins the action itself, but not the actions it calls. Where the code host offers a lock file for workflows, use it. GitHub keeps one at `.github/workflows/actions.lock`, written by the `gh actions-lock` extension, in public preview since October 2026. Its docs call the lock file the better option than hash pinning, because it covers those inner actions. Without a lock file, pin each `uses:` line to a full commit hash with the version in a comment. In GitLab CI, pin each `include:` to a commit with `ref:`. Let the update bot raise the locks after the [release cooldown](https://agentwranglers.se/playbook/application-security/supply-chain/release-cooldown.md). Read an action's code before you first lock it, since a lock proves sameness, not safety. Run the verify step in the [CI check](https://agentwranglers.se/playbook/engineering/version-control-and-review/continuous-integration.md).

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Shell example

```sh
# GitHub: write the lock file once, then verify it in every CI run
gh extension install github/gh-actions-lock
gh actions-lock            # writes .github/workflows/actions.lock
gh actions-lock --verify   # changes nothing and fails when the lock is out of date
```

### YAML example

```yaml
# GitLab CI without a lock file: pin each include to a commit
include:
  - project: example/ci-templates
    ref: 9f2c4e1b7a3d5f60e8c1b2a4d6f8e0c2b4a6d8f0
    file: /node.yml
```

### Shell example 2

```sh
# CI gate without a lock file: every uses: line names a full commit hash
if grep -rhoE 'uses: *[^ ./][^ ]*@[^ ]+' .github/workflows | grep -vE '@[0-9a-f]{40}$'; then
  echo "FAIL: action not pinned to a commit"; exit 1
fi
```

## Sources

- [GitHub workflow dependency lockfiles](https://docs.github.com/actions/concepts/security/workflow-dependency-lockfiles)
- [GitHub secure use reference](https://docs.github.com/en/actions/reference/security/secure-use)

## Related rules

- APS-72 [Wait a few days before taking new releases](https://agentwranglers.se/playbook/application-security/supply-chain/release-cooldown.md) in Application security
- ENG-16 [Run the checks on every change](https://agentwranglers.se/playbook/engineering/version-control-and-review/continuous-integration.md) in Engineering
- APS-74 [Keep secrets out of builds from strangers](https://agentwranglers.se/playbook/application-security/supply-chain/ci-secrets.md) in Application security

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/ci-dependency-lock">Agent Wranglers engineering playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Build releases without a shared cache](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/no-cache-in-release-builds.md)
- Next: [Keep untrusted text out of CI scripts](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain/ci-script-injection.md)
- [CI and supply chain](https://agentwranglers.se/playbook/engineering/ci-and-supply-chain.md)
