Skip to content

Commit 5d6e535

Browse files
committed
validate
1 parent c117453 commit 5d6e535

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Tool versions
2-
ACTIONLINT_VERSION := 1.7.10
3-
ACTION_VALIDATOR_VERSION := 0.8.0
2+
ACTIONLINT_VERSION := 1.7.12
3+
ACTION_VALIDATOR_VERSION := 0.9.0
44
GH_AW_VERSION := v0.82.10
55
GH_AW_BUILD_VERSION := v0.82.10
66
GH_AW_COMPAT_VERSION := v0.82.10
@@ -204,6 +204,7 @@ compile: setup-gh-aw setup-gh-aw-compat sync
204204
@$(MAKE) postprocess-setup-action
205205
@./scripts/backwards-compat.sh
206206
@./scripts/wire-report-failure-input.sh
207+
@./scripts/validate-uses-references.sh
207208

208209
postprocess-setup-action:
209210
@echo "Rewriting setup action references to $(GH_AW_SETUP_ACTION_REPO)@$(GH_AW_SETUP_ACTION_REF)..."
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Validate that every uses: entry with an @ includes a non-empty ref.
3+
# Example invalid line: uses: ruby/setup-ruby@ # v1.319.0
4+
set -euo pipefail
5+
6+
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
7+
WORKFLOWS_DIR="$REPO_ROOT/.github/workflows"
8+
9+
if [ ! -d "$WORKFLOWS_DIR" ]; then
10+
echo "No .github/workflows directory found; skipping uses-ref validation."
11+
exit 0
12+
fi
13+
14+
invalid_count=0
15+
16+
while IFS= read -r -d '' workflow_file; do
17+
while IFS= read -r match; do
18+
invalid_count=$((invalid_count + 1))
19+
echo "Invalid uses reference: ${workflow_file#$REPO_ROOT/}:$match"
20+
done < <(grep -nE '^[[:space:]]*uses:[[:space:]]+[^[:space:]#]+@[[:space:]]*(#.*)?$' "$workflow_file" || true)
21+
done < <(find "$WORKFLOWS_DIR" -maxdepth 1 \( -name '*.yml' -o -name '*.yaml' \) -print0)
22+
23+
if [ "$invalid_count" -gt 0 ]; then
24+
echo ""
25+
echo "Found $invalid_count invalid uses reference(s)."
26+
echo "Each uses: entry with @ must include a non-empty ref (tag, branch, or SHA)."
27+
exit 1
28+
fi
29+
30+
echo "✓ uses references validation passed"

0 commit comments

Comments
 (0)