@@ -99,7 +99,8 @@ REPO_RULESET := { \
9999
100100.PHONY : repo-settings
101101repo-settings : # # Reconcile GitHub repository settings (labels, merge strategy, branch protection, security)
102- @REPO=$$($(GH ) repo view --json nameWithOwner -q .nameWithOwner) || { echo " error: not a GitHub repository or gh not authenticated" ; exit 1; }; \
102+ @$(GH ) auth status > /dev/null 2>&1 || { echo " error: gh is not authenticated; run 'gh auth login'" ; exit 1; }; \
103+ REPO=$$($(GH ) repo view --json nameWithOwner -q .nameWithOwner) || { echo " error: not a GitHub repository" ; exit 1; }; \
103104 echo " Reconciling settings for $$ REPO..." ; \
104105 \
105106 echo " Syncing labels..." ; \
@@ -130,8 +131,44 @@ repo-settings: ## Reconcile GitHub repository settings (labels, merge strategy,
130131 echo " Created new ruleset" ; \
131132 fi ; \
132133 \
134+ echo " Installing update-action-pins workflow..." ; \
135+ mkdir -p .github/workflows; \
136+ printf ' %s\n' \
137+ ' name: Update Action Pins' \
138+ ' ' \
139+ ' on:' \
140+ ' pull_request:' \
141+ ' paths:' \
142+ ' - ".github/workflows/**"' \
143+ ' ' \
144+ ' jobs:' \
145+ ' check-pins:' \
146+ ' name: Check action pins' \
147+ ' runs-on: ubuntu-latest' \
148+ ' steps:' \
149+ ' - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4' \
150+ ' - name: Verify all actions are pinned to a SHA' \
151+ ' run: |' \
152+ ' unpinned=$$(grep -rE ' ' ^\s+(- )?uses: ' ' .github/workflows/ \' \
153+ ' | grep -vE ' ' ^\s+(- )?uses: \.\/' ' \' \
154+ ' | grep -vE ' ' @[0-9a-f]{40}($$|\s)' ' )' \
155+ ' if [[ -n "$$unpinned" ]]; then' \
156+ ' echo "::error::Found unpinned GitHub Actions (must use SHA digest, not tag):"' \
157+ ' echo "$$unpinned"' \
158+ ' echo ""' \
159+ ' echo "Run ' " '" ' GITHUB_TOKEN=$$(gh auth token) update-action-pins .github/workflows/' " '" ' to fix."' \
160+ ' exit 1' \
161+ ' fi' \
162+ > .github/workflows/update-action-pins.yml; \
163+ echo " Wrote .github/workflows/update-action-pins.yml" ; \
164+ \
133165 echo " Done."
134166
167+ .PHONY : update-action-pins
168+ update-action-pins : # # Update GitHub Action pins to their latest commit SHA
169+ @$(GH ) auth status > /dev/null 2>&1 || { echo " error: gh is not authenticated; run 'gh auth login'" ; exit 1; }; \
170+ GITHUB_TOKEN=$(gh auth token ) update-action-pins .github/workflows/
171+
135172# #@ General
136173
137174# The help target prints out all targets with their descriptions organized
0 commit comments