-
Notifications
You must be signed in to change notification settings - Fork 3
40 lines (33 loc) · 1.1 KB
/
user-validation.yml
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
name: Reject PR with IgnoreList
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
check_username:
runs-on: ubuntu-latest
env:
IGNORE_USERS: ${{ secrets.IGNORE_USERS }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Fetch all branches
run: git fetch --all
- name: Check for restricted authors in commits
id: check_commit_authors
run: |
# Convert IGNORE_USERS to an array
IFS=',' read -ra IGNORED_USERS <<< "$IGNORE_USERS"
# Get the commit authors in the pull request
COMMIT_AUTHORS=$(git log --pretty=format:"%an" origin/main..HEAD)
# Check if any commit author matches an ignored user
for AUTHOR in "${IGNORED_USERS[@]}"; do
if echo "$COMMIT_AUTHORS" | grep -iq "^$AUTHOR$"; then
echo "Restricted author '$AUTHOR' found in commits."
exit 1
fi
done
- name: PR Rejected
if: failure()
run: |
echo "This PR contains commits by restricted authors."
exit 1