Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ same name to a repository to override it.

- Trunk CLI `>=1.25.0`. The [Trunk VS Code extension](https://marketplace.visualstudio.com/items?itemName=Trunk.io), recommended in `.vscode/extensions.json`, installs the CLI.
- `gh` authenticated (`gh auth login`). The `actions-lock-verify` hook
installs the `github/gh-actions-lock` extension on first use.
installs the `github/gh-actions-lock` extension on first use, and
reinstalls it when the installed version differs from the pinned version.
- A `.github/gh-actions-lock.version` file in the consuming repository
containing the `gh-actions-lock` version to pin, for example `v0.4.0`.
Without it the pre-commit hook fails whenever workflows or actions change.
Expand Down
2 changes: 1 addition & 1 deletion .github/gh-actions-lock.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.0
v0.5.1
13 changes: 9 additions & 4 deletions scripts/actions-lock-verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# Check for any GitHub Action workflow changes. If none, exit early.
# Otherwise, install the GitHub CLI gh-actions-lock extension (if not already installed)
# Otherwise, install the GitHub CLI gh-actions-lock extension (if missing or not the pinned version)
# and verify the actions lock file.

set -euo pipefail
Expand All @@ -10,9 +10,14 @@ if git diff --cached --quiet -- .github/workflows/ ':(glob)**/action.yml' ':(glo
exit 0
fi

extensions=$(gh extension list)
if ! grep -q 'github/gh-actions-lock' <<<"${extensions}"; then
read -r version <.github/gh-actions-lock.version
read -r version <.github/gh-actions-lock.version
installed=$(gh extension list | awk -F'\t' '$2 == "github/gh-actions-lock" {print $3}')

if [[ ${installed} != "${version}" ]]; then
if [[ -n ${installed} ]]; then
gh extension remove actions-lock
fi
# --upgrade would upgrade to latest and ignore --pin, so remove and reinstall instead
gh extension install github/gh-actions-lock --pin "${version}"
fi

Expand Down