2021-09-22 09:42:17 +02:00
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 :
2021-10-13 06:59:03 +02:00
branches :
2021-10-27 14:16:10 +02:00
- main
2021-10-13 06:59:03 +02:00
- 1 .*
2022-04-08 11:54:58 +02:00
- 2 .*
2021-09-30 07:41:05 +02:00
types : [ opened ]
2021-09-22 09:42:17 +02:00
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 }}
run : |
2021-10-27 14:16:10 +02:00
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
2021-09-22 09:42:17 +02:00
curl --silent -X "GET" https://api.github.com/repos/debezium/debezium/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
2021-10-05 07:49:10 +02:00
if ! grep -qi "$AUTHOR" FILTEREDNAMES.txt; then
2023-01-11 09:09:02 +01:00
echo "USER_NOT_FOUND=true" >> $GITHUB_OUTPUT
2021-10-05 07:49:10 +02:00
fi
2021-09-22 09:42:17 +02:00
fi
fi
done < AUTHOR_NAME.txt
- name : Create comment
2023-01-11 09:09:02 +01:00
if : ${{ steps.check.outputs.USER_NOT_FOUND == 'true' }}
2023-04-10 23:03:33 +02:00
uses : peter-evans/create-or-update-comment@v3
2021-09-22 09:42:17 +02:00
with :
issue-number : ${{ github.event.pull_request.number }}
body : |
2021-10-27 14:16:10 +02:00
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.
2023-01-11 09:09:02 +01:00
- name : Check failure
if : ${{ steps.check.outputs.USER_NOT_FOUND == 'true' }}
2023-01-30 11:52:01 +01:00
uses : actions/github-script@v6
2023-01-11 09:09:02 +01:00
continue-on-error : false
with :
script : |
throw new Error('Add new user, @${{ github.event.pull_request.user.login }} to COPYRIGHT.txt and Aliases.txt')