2020-06-26 16:14:35 +02:00
name : Commit message format check
2021-08-25 09:22:31 +02:00
on :
2021-09-15 16:00:04 +02:00
# 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
2021-09-09 13:10:50 +02:00
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 .*
2020-03-12 12:44:10 +01:00
jobs :
build :
name : Commit message
runs-on : ubuntu-latest
steps :
- name : Commit messages in format DBZ-xxx
2021-09-16 05:58:11 +02:00
id : check
2020-03-12 12:44:10 +01:00
env :
2021-09-16 05:58:11 +02:00
pull_request_number : ${{ github.event.pull_request.number }}
2020-03-12 12:44:10 +01:00
run : |
2021-09-28 16:22:24 +02:00
COMMIT_MSGS=$(curl --silent -X "GET" https://api.github.com/repos/debezium/debezium/pulls/$pull_request_number/commits | jq '.[] | {message: .commit.message}' | jq '.message' | cut -c 2-)
NON_PREFIX_COMMITS=""
while IFS= read -r line ;
2021-09-16 05:58:11 +02:00
do
2021-09-28 16:22:24 +02:00
line=${line%\"}
echo "-> checking: $line"
2021-10-05 07:38:53 +02:00
if [[ ! $line =~ (^DBZ-[[:digit:]]+)|(\[release\])|(\[jenkins-jobs\])|(\[docs\])|(\[maven-release-plugin\])|(\[ci\]) ]]; then
2021-09-28 16:22:24 +02:00
NON_PREFIX_COMMITS="${NON_PREFIX_COMMITS} -> ${line} \n"
2021-09-16 05:58:11 +02:00
fi
2021-09-28 16:22:24 +02:00
done <<< "$COMMIT_MSGS"
if [[ $NON_PREFIX_COMMITS != "" ]]; then
echo "========================================================================"
echo " COMMIT MESSAGES WITH MISSING \"DBZ\" PREFIX"
echo "========================================================================"
echo -e "$NON_PREFIX_COMMITS"
echo "::set-output name=PREFIX::false"
fi
2021-09-09 13:10:50 +02:00
- name : Create Comment
2021-09-16 05:58:11 +02:00
if : ${{ steps.check.outputs.PREFIX == 'false' }}
2021-09-09 13:10:50 +02:00
uses : peter-evans/create-or-update-comment@v1
with :
issue-number : ${{ github.event.pull_request.number }}
body : |
2021-10-27 14:16:10 +02:00
Hi @${{ github.event.pull_request.user.login }}, thanks for your contribution. Please prefix the commit message(s) with the [DBZ-xxx JIRA issue key](https://github.com/debezium/debezium/blob/main/CONTRIBUTE.md#making-changes).
2022-02-04 15:23:18 +01:00
- name : Check failure
if : ${{ steps.check.outputs.PREFIX == 'false' }}
uses : actions/github-script@v5
continue-on-error : false
with :
script : |
throw new Error('Commit has no DBZ-xxx prefiix')