Skip to content

Commit 9fec4ed

Browse files
Add GitHub Action to check commit authors to prevent sus commits
1 parent 50df6e7 commit 9fec4ed

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Check Commit Author
2+
on: push
3+
jobs:
4+
author-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v4
9+
- name: Verify commit authors
10+
run: |
11+
# List of banned authors and emails (case-insensitive). You can add more.
12+
banned_authors=("linus torvalds" "satoshi nakamoto" "elon musk")
13+
14+
15+
# Get all authors and emails in the push range
16+
authors=$(git log --format='%an' ${{ github.event.before }}..${{ github.sha }})
17+
emails=$(git log --format='%ae' ${{ github.event.before }}..${{ github.sha }})
18+
19+
# Check names
20+
for banned in "${banned_authors[@]}"; do
21+
if echo "$authors" | grep -i "$banned"; then
22+
echo "Blocked: Commit attributed to banned author '$banned'."
23+
exit 1
24+
fi
25+
done
26+
27+
# Check emails
28+
for email in "${banned_emails[@]}"; do
29+
if echo "$emails" | grep -i "$email"; then
30+
echo "Blocked: Commit attributed to banned email '$email'."
31+
exit 1
32+
fi
33+
done
34+
35+
echo "Author check passed. No banned commit authors found."

0 commit comments

Comments
 (0)