3434 run : htmlhint "**/*.html" || true
3535
3636 # -------------------
37- # 2. DCO + GPG Check (latest commit only)
37+ # 2. DCO + GPG Check
38+ # 2.1 Commit Verification (GPG + Trust)
3839 # -------------------
3940 commit-checks :
4041 runs-on : ubuntu-latest
@@ -49,73 +50,42 @@ jobs:
4950 if : github.event_name == 'pull_request'
5051 uses : tisonkun/actions-dco@v1.1
5152
52- # ---------- Import GPG Public Key ----------
53- - name : Import trusted GPG public key
54- if : ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }}
55- env :
56- GPG_PUBLIC_KEY : ${{ secrets.GPG_PUBLIC_KEY }}
57- GPG_PUBLIC_KEY_1 : ${{ secrets.GPG_PUBLIC_KEY_1 }}
53+ - name : Import GPG public keys
5854 run : |
59- # Check for primary GPG key
60- if [ -z "$GPG_PUBLIC_KEY" ] && [ -z "$GPG_PUBLIC_KEY_1" ]; then
61- echo "⚠️ Skipping GPG import: No secrets available (forked PR or missing keys)."
62- exit 0
55+ if [ -n "${{ secrets.GPG_PUBLIC_KEY }}" ]; then
56+ echo "${{ secrets.GPG_PUBLIC_KEY }}" | gpg --import
57+ echo "✅ Imported GPG_PUBLIC_KEY"
6358 fi
6459
65- # Function to import and trust a GPG key
66- import_key() {
67- local key="$1"
68- local varname="$2"
69- if [ -n "$key" ]; then
70- echo "$key" | gpg --import
71- echo "✅ Imported $varname successfully."
72- fingerprint=$(echo "$key" | gpg --with-colons --import-options show-only --import 2>/dev/null | awk -F: '$1=="fpr"{print $10; exit}')
73- if [ -n "$fingerprint" ]; then
74- echo "$fingerprint:6:" | gpg --import-ownertrust
75- echo "🔐 Set $varname ($fingerprint) to ultimate trust."
76- fi
77- fi
78- }
79-
80- # Import your own keys
81- import_key "$GPG_PUBLIC_KEY" "GPG_PUBLIC_KEY"
82- import_key "$GPG_PUBLIC_KEY_1" "GPG_PUBLIC_KEY_1"
83-
84- # ✅ Import GitHub’s official signing keys (commit + merge)
85- echo "🌐 Importing GitHub official GPG signing keys..."
86- curl -fsSL https://github.com/web-flow.gpg | gpg --import || true
87- curl -fsSL https://github.com/actions/runner-images/blob/main/images/github-bot.gpg?raw=true | gpg --import || true
88- echo "✅ Imported GitHub web-flow and merge bot keys successfully."
89-
90- echo "🎉 All available GPG public keys imported successfully."
91-
92- # ---------- Verify latest commit signature ----------
60+ if [ -n "${{ secrets.GPG_PUBLIC_KEY_1 }}" ]; then
61+ echo "${{ secrets.GPG_PUBLIC_KEY_1 }}" | gpg --import
62+ echo "✅ Imported GPG_PUBLIC_KEY_1"
63+ fi
64+
65+ # ---------- Verify latest commit ----------
9366 - name : Verify latest commit signature
94- if : ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }}
9567 run : |
96- LATEST_COMMIT=$(git rev-parse HEAD)
97- echo "🔍 Checking latest commit: $LATEST_COMMIT"
98-
99- SIG=$(git log --show-signature -1 "$LATEST_COMMIT")
100- echo "$SIG"
101-
102- # ✅ Include all trusted fingerprints
103- TRUSTED_KEYS="7F4C7CA953E1C09E D432152833DA3244 88F6CD4E295C9062 BE677DAEFE33CB57 C97540DA6C9FA85C"
104- GITHUB_COMMIT_KEY="4AEE18F83AFDEB23" # GitHub web-flow
105- GITHUB_MERGE_KEY="B5690EEEBB952194" # GitHub merge bot
106- TRUSTED="$TRUSTED_KEYS $GITHUB_COMMIT_KEY $GITHUB_MERGE_KEY"
107-
108- if echo "$SIG" | grep -q "Good signature"; then
109- for key in $TRUSTED; do
110- if echo "$SIG" | grep -q "$key"; then
111- echo "✅ Commit signed with trusted key: $key"
112- exit 0
113- fi
114- done
68+ LATEST_COMMIT=${{ github.event.pull_request.head.sha }}
69+ echo "🔍 Verifying commit: $LATEST_COMMIT"
70+
71+ if git verify-commit "$LATEST_COMMIT" >/dev/null 2>&1; then
72+ echo "✅ Signature is cryptographically valid"
73+ else
74+ echo "❌ Invalid or missing GPG signature"
75+ exit 1
11576 fi
11677
117- echo "❌ Commit is not GPG signed with a trusted key!"
118- exit 1
78+ FINGERPRINT=$(git log -1 --pretty=format:'%GF' "$LATEST_COMMIT")
79+ echo "🔑 Signing fingerprint: $FINGERPRINT"
80+
81+ TRUSTED_KEYS="83FB991D930D7177F25456C07F4C7CA953E1C09E D432152833DA3244 4AEE18F83AFDEB23 B5690EEEBB952194"
82+
83+ if echo "$TRUSTED_KEYS" | grep -q "$FINGERPRINT"; then
84+ echo "✅ Trusted signer"
85+ else
86+ echo "❌ Untrusted signing key!"
87+ exit 1
88+ fi
11989
12090 # ---------- Optional status for skipped forked PRs ----------
12191 - name : Skip GPG checks for external PRs
0 commit comments