Skip to content

Commit 16926dd

Browse files
committed
Scan for @v actions
1 parent 8981d01 commit 16926dd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

.github/workflows/pr-build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ on:
66
- main
77

88
jobs:
9+
static-code-checks:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Check for versioned GitHub actions
17+
if: always()
18+
run: |
19+
# Get changed GitHub workflow/action files
20+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E "^\.github/(workflows|actions)/.*\.ya?ml$" || true)
21+
22+
if [ -n "$CHANGED_FILES" ]; then
23+
# Check for any versioned actions, excluding comments and this validation script
24+
VIOLATIONS=$(grep -Hn "uses:.*@v" $CHANGED_FILES | grep -v "grep.*uses:.*@v" | grep -v "#.*@v" || true)
25+
if [ -n "$VIOLATIONS" ]; then
26+
echo "Found versioned GitHub actions. Use commit SHAs instead:"
27+
echo "$VIOLATIONS"
28+
exit 1
29+
fi
30+
fi
31+
32+
echo "No versioned actions found in changed files"
33+
934
build:
1035
name: Gradle Build
1136
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)