11name : PR Quality Gate
22
3+ # 🔒 SECURITY: Use manual trigger only for self-hosted runners
4+ # This prevents forks from automatically running code on your machine
35on :
46 workflow_dispatch :
7+ inputs :
8+ branch :
9+ description : ' Branch to check'
10+ required : true
11+ default : ' main'
512
613jobs :
714 pr-quality :
8- runs-on : ubuntu-latest
15+ runs-on : self-hosted
916
1017 steps :
18+ - name : Cleanup Workspace
19+ run : rm -rf ./*
20+
1121 - name : Checkout code
1222 uses : actions/checkout@v4
1323 with :
24+ ref : ${{ inputs.branch }}
1425 fetch-depth : 0
1526
1627 - name : Setup Node.js
@@ -19,29 +30,26 @@ jobs:
1930 node-version : " 20.x"
2031 cache : " npm"
2132
22- - name : Install dependencies
23- run : npm ci
33+ - name : Install dependencies (Safe Mode)
34+ # 🛡️ SECURITY: --ignore-scripts prevents malicious postinstall scripts
35+ # from executing on your local machine.
36+ run : npm ci --ignore-scripts
2437
25- - name : Check PR title format
26- run : |
27- # This check is informational for manual runs.
28- # In a real PR context, you would use github.event.pull_request.title
29- echo "Note: This check is for a manual run. In a PR, it would validate the title."
30-
3138 - name : Check for large files
3239 run : |
40+ echo "🔍 Scanning for large files (>1MB)..."
3341 find . -type f -size +1M -not -path "./node_modules/*" -not -path "./.git/*" | while read file; do
3442 echo "::warning::Large file detected: $file ($(du -h "$file" | cut -f1))"
3543 done
3644
3745 - name : Lint commit messages
3846 run : |
39- echo "Note: This check is for a manual run. In a PR, it would lint commit messages ."
47+ echo "🔍 Verifying Conventional Commits.. ."
4048 if git rev-parse --verify HEAD~1 >/dev/null 2>&1; then
4149 git log --oneline HEAD~1..HEAD | while read line; do
4250 if [[ ! "$line" =~ ^[a-f0-9]+\ (feat|fix|docs|style|refactor|test|chore|perf|ci)(\(.+\))?: ]]; then
43- echo "::warning::Commit message should follow conventional commits: $line"
51+ echo "::warning::Invalid Commit Message: $line"
52+ echo "::warning::Format should be: type(scope): description"
4453 fi
4554 done
4655 fi
47-
0 commit comments