Skip to content

Commit f36a8ce

Browse files
committed
feat: prevent versioned 3P GitHub actions in PR builds
Add validation step to require commit SHAs instead of version tags for third-party GitHub actions in workflow files.
1 parent a1ce74e commit f36a8ce

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

.github/workflows/pr-build.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ permissions:
1616
contents: read
1717

1818
jobs:
19-
changelog-check:
19+
static-code-checks:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #5.0.0
2323
with:
2424
fetch-depth: 0
2525

2626
- name: Check CHANGELOG
27+
continue-on-error: true
2728
run: |
2829
# Check if PR is from workflows bot or dependabot
2930
if [[ "${{ github.event.pull_request.user.login }}" == "aws-application-signals-bot" ]]; then
@@ -52,6 +53,28 @@ jobs:
5253
echo "It looks like you didn't add an entry to CHANGELOG.md. If this change affects the SDK behavior, please update CHANGELOG.md and link this PR in your entry. If this PR does not need a CHANGELOG entry, you can add the 'Skip Changelog' label to this PR."
5354
exit 1
5455
56+
- name: Check for versioned GitHub actions
57+
continue-on-error: true
58+
run: |
59+
# Get changed GitHub workflow/action files
60+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD | grep -E "^\.github/(workflows|actions)/.*\.ya?ml$" || true)
61+
62+
if [ -n "$CHANGED_FILES" ]; then
63+
# Check for any versioned actions
64+
VIOLATIONS=$(grep -Hn "uses:.*@v" $CHANGED_FILES || true)
65+
if [ -n "$VIOLATIONS" ]; then
66+
echo "Found versioned GitHub actions. Use commit SHAs instead:"
67+
echo "$VIOLATIONS"
68+
exit 1
69+
fi
70+
fi
71+
72+
echo "No versioned actions found in changed files"
73+
74+
- name: Fail if any of the above checks failed
75+
if: failure()
76+
run: exit 1
77+
5578
build:
5679
runs-on: ubuntu-latest
5780
strategy:

0 commit comments

Comments
 (0)