2024-07-01 06:09:07 -04:00
# yamllint disable-line rule:line-length
# SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
---
name : Reject pull requests of user's that don't read the contribution guidelines
# yamllint disable-line rule:truthy
on :
pull_request :
types :
- opened
- reopened
- synchronize
jobs :
2024-07-01 07:42:20 -04:00
reject-pr :
permissions :
contents : read
pull-requests : write
2024-07-01 06:09:07 -04:00
strategy :
fail-fast : false
runs-on : ubuntu-24.04
steps :
- uses : actions/checkout@v4
with :
fetch-depth : 0
- name : Block commits made using the GitHub WebUI
2024-07-01 06:18:46 -04:00
id : check_committer
2024-07-01 06:09:07 -04:00
run : |
if test "${{ github.event_name}}" = "pull_request"
then
base="${{ github.event.pull_request.base.sha }}"
head="${{ github.event.pull_request.head.sha }}"
else
base="${{ github.event.before }}"
head="${{ github.event.after }}"
fi
if test "${base}" = "${head}" || test -z "${base}"
then
committer="$(git show -s --format=%cn ${head})"
else
committer="$(git show -s --format=%cn ${base}..${head})"
fi
if echo "${committer}" | grep -q "^GitHub$"; then
2024-07-01 06:18:46 -04:00
echo "committer_gitweb=true" >> $GITHUB_OUTPUT
2024-07-01 06:09:07 -04:00
echo "Commit was made using the GitHub WebUI" >&2
fi
2024-07-01 06:18:46 -04:00
- name : Block commits made using the GitHub WebUI
2024-07-01 06:24:27 -04:00
if : steps.check_committer.outputs.committer_gitweb == 'true'
2024-07-01 06:18:46 -04:00
uses : peter-evans/close-pull@v3
with :
# yamllint disable-line rule:line-length
comment : 'Automatically closing this PR due to submitter not reading the contribution guidelines and using GitHub WebUI to commit. Please fix the issues and open a new PR after you have read the contribution guidelines.'
delete-branch : false