-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (33 loc) · 1.27 KB
/
check_author_commits.yml
File metadata and controls
38 lines (33 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Check Commit Author
on: push
jobs:
author-check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1 # only fetches the latest commit
- name: Verify current commit author
run: |
# List of banned authors and emails
banned_authors=("linus torvalds" "satoshi nakamoto" "elon musk")
banned_emails=("torvalds@linux-foundation.org" "satoshi@bitcoin.org" "elon@spacex.com")
# Get author name and email for the current commit only
author=$(git show -s --format='%an' ${{ github.sha }})
email=$(git show -s --format='%ae' ${{ github.sha }})
# Check banned authors
for banned in "${banned_authors[@]}"; do
if [[ "${author,,}" == "${banned,,}" ]]; then
echo "Blocked: Commit attributed to banned author '$banned'."
exit 1
fi
done
# Check banned emails
for banned in "${banned_emails[@]}"; do
if [[ "${email,,}" == "${banned,,}" ]]; then
echo "Blocked: Commit attributed to banned email '$banned'."
exit 1
fi
done
echo "Author check passed. No banned commit author found."