Skip to content

Commit 9f52e07

Browse files
ci: prevent merge-requests in a PR
Have the CI prevent merge-requests being part of a PR
1 parent 48726fd commit 9f52e07

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

.github/workflows/lint.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,20 @@ jobs:
4141
run: tox -e isort -- --check
4242
- name: Run pylint Python code static checker (https://github.com/PyCQA/pylint)
4343
run: tox -e pylint
44+
- name: Ensure no merge-commits in the Pull Request (PR)
45+
run: |
46+
set -x
47+
echo "event name is: ${{ github.event_name }}"
48+
git --version
49+
git log --oneline | head
50+
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}"
51+
echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}"
52+
echo "GITHUB_SHA: ${GITHUB_SHA}"
53+
echo "github.event.pull_request.head.sha: ${{ github.event.pull_request.head.sha }}"
54+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
55+
MERGE_COMMITS=$(git rev-list --merges origin/${GITHUB_BASE_REF}..${HEAD_SHA})
56+
if [[ -n "${MERGE_COMMITS}" ]]; then
57+
echo "ERROR: The Pull Request (PR) contains a 'merge commit': ${MERGE_COMMITS}"
58+
exit 1
59+
fi
60+
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)