Skip to content

Commit 3f51cc3

Browse files
authored
Add Sigscanner workflow (#24)
* Add Sigscanner workflow * Add README * Add CODEOWNER
1 parent ada8829 commit 3f51cc3

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* @smartcontractkit/devex-cicd
2+
.github/workflows/sigscanner-check.yml @smartcontractkit/prodsec-public
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: "SigScanner Check"
2+
3+
on:
4+
merge_group:
5+
pull_request:
6+
7+
permissions: {}
8+
9+
jobs:
10+
sigscanner-check:
11+
runs-on: ubuntu-latest
12+
# Skip on merge group events
13+
if: ${{ github.event_name == 'pull_request' }}
14+
steps:
15+
- name: "SigScanner checking ${{ github.sha }} by ${{ github.actor }}"
16+
env:
17+
API_TOKEN: ${{ secrets.SIGSCANNER_API_TOKEN }}
18+
API_URL: ${{ secrets.SIGSCANNER_API_URL }}
19+
COMMIT_SHA: ${{ github.sha }}
20+
ACTOR: ${{ github.actor }}
21+
REPOSITORY: ${{ github.repository }}
22+
EVENT_NAME: ${{ github.event_name }}
23+
24+
run: |
25+
echo "🔎 Checking commit $COMMIT_SHA by $ACTOR in $REPOSITORY - $EVENT_NAME"
26+
27+
payload=$(printf '{"commit":"%s","repository":"%s","author":"%s"}' \
28+
"$COMMIT_SHA" "$REPOSITORY" "$ACTOR")
29+
30+
max_attempts=3
31+
attempt=1
32+
33+
# Retry on 5XXs
34+
while [[ $attempt -le $max_attempts ]]; do
35+
echo "Attempt $attempt/$max_attempts"
36+
37+
CODE=$(curl \
38+
--silent \
39+
--output /dev/null \
40+
--write-out '%{http_code}' \
41+
--max-time 20 \
42+
-X POST \
43+
-H "Content-Type: application/json" \
44+
-H "Authorization: $API_TOKEN" \
45+
--url "$API_URL" \
46+
--data "$payload")
47+
48+
echo "Received $CODE"
49+
if [[ "$CODE" == "200" ]]; then
50+
echo "✅ Commit is verified"
51+
exit 0
52+
elif [[ "$CODE" == "400" ]]; then
53+
echo "❌ Bad request"
54+
exit 1
55+
elif [[ "$CODE" == "403" ]]; then
56+
echo "❌ Commit is NOT verified"
57+
exit 1
58+
elif [[ "$CODE" =~ ^5[0-9][0-9]$ ]]; then
59+
if [[ $attempt -lt $max_attempts ]]; then
60+
echo "Retrying in 15s..."
61+
sleep 15
62+
fi
63+
else
64+
echo "❌ Unexpected response"
65+
exit 1
66+
fi
67+
68+
attempt=$((attempt + 1))
69+
done
70+
exit 1

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Uses [patrickhuie19/codeowners-validator](https://github.com/patrickhuie19/codeo
2727

2828
Enforces that every repository has a CODEOWNERS file.
2929

30+
### Sigscanner check
31+
32+
Enforces that commits are signed by allowlisted keys.
33+
3034
## Help
3135

3236
If you are experiencing a blocking error from a workflow in this repository, please reach out to us on `#team-devex`.

0 commit comments

Comments
 (0)