Skip to content

Commit 1b5ff06

Browse files
Add a sample workflow that verifies the lockfile in CI (#233)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 4cf118d commit 1b5ff06

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎.github/workflows/actions.lock‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ workflows:
1212
'.github/workflows/test.yml':
1313
- 'actions/checkout@v7.0.1'
1414
- 'actions/setup-go@v7.0.0'
15+
'.github/workflows/verify-lockfile.yml':
16+
- 'actions/checkout@v7.0.1'
1517
dependencies:
1618
'actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32':
1719
ref: 'v4.1.0'
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Fails when .github/workflows/actions.lock is out of sync with the
2+
# workflows or a locked pin no longer verifies upstream. Copy this file
3+
# into your repository's .github/workflows/ and run `gh actions-lock` once
4+
# to add it to your lockfile.
5+
#
6+
# --verify is read-only and calls the GitHub API to check every pin. The
7+
# job's GITHUB_TOKEN can read public actions and this repository; if your
8+
# workflows use actions from other private or internal repositories, pass
9+
# a token that can read them instead. --verify-local works offline but only
10+
# checks lockfile coverage, not that the pins are trustworthy.
11+
#
12+
# Exit codes: 0 valid, 1 findings to fix, 2 the check itself failed.
13+
14+
name: verify-lockfile
15+
16+
on:
17+
pull_request:
18+
push:
19+
branches:
20+
- main
21+
# Catches upstream changes, like a re-pointed tag, between pull requests.
22+
schedule:
23+
- cron: '17 6 * * 1'
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
verify:
30+
runs-on: ubuntu-latest
31+
env:
32+
GH_TOKEN: ${{ github.token }}
33+
steps:
34+
- uses: actions/checkout@v7.0.1
35+
with:
36+
persist-credentials: false
37+
- run: gh extension install github/gh-actions-lock --pin v0.2.0
38+
- run: gh actions-lock --verify

‎README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ To check without writing anything, for example in CI, run:
6060
gh actions-lock --verify
6161
```
6262

63+
For a ready-to-copy CI job that runs this on pull requests, see
64+
[`.github/workflows/verify-lockfile.yml`](.github/workflows/verify-lockfile.yml).
65+
6366
If the GitHub API is unreachable or rate-limited, `--verify` retries for up to
6467
about 2 minutes in CI (a few seconds elsewhere), then fails (exit 1) with the pins it couldn't verify. Their
6568
`--json` findings carry `"retryable": true`; re-run the check once the API is

0 commit comments

Comments
 (0)