Skip to content

Commit 510c8fb

Browse files
committed
ci: enforce Pinned-Dependencies check in CI for PRs
1 parent a80c2d4 commit 510c8fb

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

.github/workflows/scorecard.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ on:
1818
# To guarantee Maintained check is occasionally updated. See
1919
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
2020
schedule:
21-
- cron: '29 15 * * 6'
21+
- cron: "29 15 * * 6"
2222
push:
23-
branches: [ "main" ]
23+
branches: ["main"]
24+
# Add pull_request trigger to check PRs
25+
pull_request:
26+
branches: ["main"]
2427

2528
# Declare default permissions as read only.
2629
permissions: read-all
@@ -55,6 +58,24 @@ jobs:
5558
# - See https://github.com/ossf/scorecard-action#publishing-results.
5659
publish_results: true
5760

61+
# Enable only Pinned-Dependencies check
62+
checks: pinned-dependencies
63+
64+
# Add step to fail if Pinned-Dependencies check fails
65+
- name: "Check Pinned Dependencies Score"
66+
run: |
67+
score=$(jq -r '.runs[0].results[] | select(.ruleId=="pinned-dependencies") | .score' results.sarif)
68+
if (( $(echo "$score < 9" | bc -l) )); then
69+
echo "Pinned-Dependencies check failed with score: $score"
70+
echo "Please ensure all dependencies are pinned to specific versions."
71+
echo "Common locations to check:"
72+
echo "- GitHub Actions workflow files (.github/workflows/*.yml)"
73+
echo "- Package manager files (package.json, requirements.txt, etc.)"
74+
echo "- Docker images in Dockerfiles"
75+
exit 1
76+
fi
77+
echo "Pinned-Dependencies check passed with score: $score"
78+
5879
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
5980
# format to the repository Actions tab.
6081
- name: "Upload artifact"
@@ -69,3 +90,11 @@ jobs:
6990
uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
7091
with:
7192
sarif_file: results.sarif
93+
94+
# Reference to the main all-jobs-succeed job
95+
all-jobs-succeed:
96+
needs: [analysis]
97+
if: false # This job never runs, it's just for dependency tracking
98+
runs-on: ubuntu-latest
99+
steps:
100+
- run: echo "This job is never executed, it exists only for dependency tracking"

0 commit comments

Comments
 (0)