Sub topic 3
Workflow Dependency Lockfiles: The Idea
Assume you know basic GitHub Actions syntax, Git commits and tags, and package-manager lockfiles. A workflow dependency lockfile is a generated manifest that records the exact revisions used by workflow dependencies. It can include direct actions and dependencies nested inside composite actions or reusable workflows.
Why use a lockfile?
Manual SHA pinning makes a direct reference reproducible:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2A lockfile extends this idea. It records each dependency's source, requested reference, resolved commit SHA, and often its version or integrity information.
The lockfile is usually generated by a third-party tool or repository workflow. GitHub Actions does not automatically create one for every repository.
Generate, review, and update
A typical process is:
- Run the lockfile tool against workflow files.
- Review the generated changes. Confirm repositories, tags, SHAs, and nested dependencies.
- Commit the lockfile with the workflow changes.
- Regenerate it when Dependabot or a maintainer approves an action update.
Forks, reusable workflows, and images
A commit reachable through a fork can be the same Git object as an upstream commit. That does not make every commit from that fork an approved release. Check the intended upstream repository, tag, and release history.
Pin reusable workflows by commit SHA too:
jobs:
deploy:
uses: example-org/ci/.github/workflows/deploy.yml@<full-commit-sha>Pin Docker-based actions by digest rather than tag:
- uses: docker://alpine@sha256:<image-digest>Choosing a strategy
Manual SHA pins are simple and visible, but they can miss nested dependencies. Lockfiles improve coverage and repeatability, but add tooling, review, and update work. Dependabot can propose updates for direct action pins, while a lockfile tool must also refresh resolved transitive dependencies.
Pinning cannot fix malicious code already present in a trusted commit, unsafe workflow permissions, compromised credentials, or an unreviewed update. Use least-privilege permissions and review updates.
Exercise
What does a workflow lockfile add beyond pinning a top-level action to a SHA?
Show answer
It records resolved revisions for direct and, when supported, transitive workflow dependencies, making the complete dependency set reproducible.