-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (40 loc) · 1.47 KB
/
Copy pathcommit-author.yml
File metadata and controls
45 lines (40 loc) · 1.47 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
39
40
41
42
43
44
45
name: Commit author guard
on:
pull_request:
branches: [main]
push:
branches: [main]
permissions:
contents: read
jobs:
verify-author:
name: Verify all commits are authored by valeh.agayev@gmail.com
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commit authors
run: |
set -euo pipefail
# On PRs, GitHub gives us the merge commit; we want the actual commits.
if [ -n "${GITHUB_BASE_REF:-}" ]; then
range="origin/${GITHUB_BASE_REF}..HEAD"
else
# Push to main: check this push only.
range="${{ github.event.before }}..${{ github.event.after }}"
# Skip empty/initial pushes.
if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then
range="HEAD~1..HEAD"
fi
fi
echo "Checking range: $range"
bad=$(git log "$range" --pretty=format:'%ae' | grep -v -i '^valeh\.agayev@gmail\.com$' || true)
if [ -n "$bad" ]; then
echo "::error::Commits from disallowed authors found:"
git log "$range" --pretty=format:'%h %ae %s' | grep -v -i 'valeh\.agayev@gmail\.com'
echo ""
echo "Project policy: every commit must be authored by valeh.agayev@gmail.com (valehdba)."
exit 1
fi
echo "All commits authored by valeh.agayev@gmail.com ✅"