Skip to content

Commit f72f107

Browse files
2 parents d4c90e1 + 14b71c2 commit f72f107

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
with:
10+
fetch-depth: 1 # only fetches the latest commit
11+
12+
- name: Verify current commit author
13+
run: |
14+
# List of banned authors and emails
15+
banned_authors=("linus torvalds" "satoshi nakamoto" "elon musk")
16+
17+
18+
# Get author name and email for the current commit only
19+
author=$(git show -s --format='%an' ${{ github.sha }})
20+
email=$(git show -s --format='%ae' ${{ github.sha }})
21+
22+
# Check banned authors
23+
for banned in "${banned_authors[@]}"; do
24+
if [[ "${author,,}" == "${banned,,}" ]]; then
25+
echo "Blocked: Commit attributed to banned author '$banned'."
26+
exit 1
27+
fi
28+
done
29+
30+
# Check banned emails
31+
for banned in "${banned_emails[@]}"; do
32+
if [[ "${email,,}" == "${banned,,}" ]]; then
33+
echo "Blocked: Commit attributed to banned email '$banned'."
34+
exit 1
35+
fi
36+
done
37+
38+
echo "Author check passed. No banned commit author found."

0 commit comments

Comments
 (0)