This repository has been archived by the owner on Sep 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
51 lines (49 loc) · 2.59 KB
/
contributor-check.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
41
42
43
44
45
46
47
48
49
50
51
name: Contributor Check
on:
# ATTENTION: See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
# re security implications of using this trigger; in particular, no code from PR branches must
# be executed in any flows triggered by it
pull_request_target:
branches:
- main
- 1.*
- 2.*
types: [ opened ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check if COPYRIGHT.txt has author name?
id: check
env:
pull_request_number: ${{ github.event.pull_request.number }}
github_repository: ${{ github.repository }}
run: |
curl -H 'Accept: application/vnd.github.v3.raw' https://raw.githubusercontent.com/debezium/debezium/main/COPYRIGHT.txt >> COPYRIGHT.txt
curl -H 'Accept: application/vnd.github.v3.raw' https://raw.githubusercontent.com/debezium/debezium/main/jenkins-jobs/scripts/config/Aliases.txt >> ALIASES.txt
curl -H 'Accept: application/vnd.github.v3.raw' https://raw.githubusercontent.com/debezium/debezium/main/jenkins-jobs/scripts/config/FilteredNames.txt >> FILTEREDNAMES.txt
curl --silent -X "GET" https://api.github.com/repos/$github_repository/pulls/$pull_request_number/commits | jq '.[] | {author: .commit.author.name}' | jq -r '.author' | uniq >> AUTHOR_NAME.txt
while IFS=" " read -r AUTHOR;
do
if ! grep -qi "$AUTHOR" COPYRIGHT.txt; then
if ! grep -qi "$AUTHOR" ALIASES.txt; then
if ! grep -qi "$AUTHOR" FILTEREDNAMES.txt; then
echo "USER_NOT_FOUND=true" >> $GITHUB_OUTPUT
fi
fi
fi
done < AUTHOR_NAME.txt
- name: Create comment
if: ${{ steps.check.outputs.USER_NOT_FOUND == 'true' }}
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
Welcome as a new contributor to Debezium, @${{ github.event.pull_request.user.login }}. Reviewers, please add missing author name(s) and alias name(s) to the [COPYRIGHT.txt](https://github.com/debezium/debezium/blob/main/COPYRIGHT.txt) and [Aliases.txt](https://github.com/debezium/debezium/blob/main/jenkins-jobs/scripts/config/Aliases.txt) respectively.
- name: Check failure
if: ${{ steps.check.outputs.USER_NOT_FOUND == 'true' }}
uses: actions/github-script@v7
continue-on-error: false
with:
script: |
throw new Error('Add new user, @${{ github.event.pull_request.user.login }} to COPYRIGHT.txt and Aliases.txt')