qusal/.github/workflows/reject-pr.yaml

57 lines
1.9 KiB
YAML
Raw Normal View History

# 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
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
id: check_committer
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
echo "committer_gitweb=true" >> $GITHUB_OUTPUT
echo "Commit was made using the GitHub WebUI" >&2
fi
- name: Block commits made using the GitHub WebUI
if: steps.check_committer.outputs.committer_gitweb == 'true'
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