Sub topic 10
Generating, reviewing, and updating a lockfile
This chapter assumes you can pin an action to a full-length commit SHA, that you know why composite actions and reusable workflows leave transitive references unpinned, and that you have used a lockfile such as package-lock.json. It covers the day-to-day routine of a workflow lockfile.
The file name, the commands, and the schema depend on the tool you use. The examples here show a representative shape, not one tool's exact format. Check your tool's documentation for the real names.
Generating the lockfile
Generation resolves every uses: reference in your workflows to a commit SHA. It then follows each action's own uses: references and resolves those too. The result is written to a file committed next to the workflows.
A representative lockfile looks like this. The second SHA is a placeholder.
lockfile_version: 1
dependencies:
- uses: actions/checkout@v4
resolved: 11bd71901bbe5b1630ceea73d27597364c9af683
required_by: [".github/workflows/ci.yml"]
- uses: some-org/some-action@v1
resolved: 0123456789abcdef0123456789abcdef01234567
required_by: ["./.github/actions/setup-tools"]Three details matter:
- Your workflow can keep the readable tag, such as
@v4. The lockfile holds the exact commit. - The
some-org/some-action@v1entry is a transitive dependency. Manual pinning would have missed it. required_byshows why each entry exists, which helps when you review.
Run generation on a clean branch and commit the lockfile in the same pull request as any workflow change.
Reviewing a lockfile change
A lockfile diff is the main place a person can catch a bad update. Review it like a dependency bump, not like generated noise.
- uses: some-org/some-action@v1
- resolved: 0123456789abcdef0123456789abcdef01234567
+ resolved: fedcba9876543210fedcba9876543210fedcba98
required_by: ["./.github/actions/setup-tools"]Check these points for each changed line:
- Was the change intended? A SHA that changes when you edited no workflow means a tag moved. Find out why before merging.
- Does the new SHA belong to the right repository? Use the verification steps from the chapter on resolving SHAs. A SHA can exist in a fork and still resolve in the parent repository's namespace.
- Is the version jump reasonable? Read the release notes or the commit range between the old and new SHA.
- Did new entries appear? A new transitive dependency means an action you use began calling another action. Treat it as a new trust decision.
flowchart TDUpdating the lockfile
Pins only protect you while they are current, so updates need a routine.
- Intentional update. Run the tool's update command for one dependency, or for all of them. Review the diff and merge.
- Automated update. Dependabot can open pull requests for action updates, as covered earlier. Confirm that your lockfile tool also regenerates the file in those pull requests. If it does not, add a CI check that fails when the lockfile is out of date relative to the workflows.
- Security fix. When an action publishes a fix, update that one dependency straight away. Include transitive entries, because the vulnerable code may sit one level down.
A useful CI check reruns generation and fails if the result differs from the committed file. This catches a hand-edited workflow whose lockfile was never refreshed.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| Lockfile changes with no workflow edit | A tag was moved upstream | Investigate before merging. Keep the old SHA until you understand it. |
| CI fails with "lockfile out of date" | A workflow changed but the lockfile did not | Regenerate and commit both together |
| Merge conflicts in the lockfile | Two branches updated different actions | Regenerate on the merged branch, not by hand |
| A transitive entry is missing | Generation ran against an older workflow | Rerun generation and check `required_by` |
Do not resolve lockfile conflicts by editing SHAs manually. A hand-edited SHA is exactly the unreviewed trust that the file exists to prevent.
Exercise
A pull request changes only the lockfile. One resolved SHA for a transitive action differs from the previous one, and no workflow file was edited. Name two checks you do before approving.
Show answer
First, find out why the SHA changed, for example by comparing the old and new commits and reading the release notes, since the tag probably moved or the parent action updated its own reference. Second, verify that the new SHA belongs to the intended repository and not to a fork. Also confirm that the lockfile regenerates cleanly from the workflows.