CI: Add workflow to enforce rebase before merge #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Force rebased | |
on: [pull_request] | |
jobs: | |
force-rebase: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'PR commits + 1' | |
run: echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}" | |
- name: 'Checkout PR branch and all PR commits' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: ${{ env.PR_FETCH_DEPTH }} | |
- name: Is Rebased on master? | |
shell: bash | |
run: | | |
merges="\$(git log --oneline HEAD^${{ env.PR_FETCH_DEPTH }}...HEAD --merges )"; \ | |
echo "--- Merges ---\\n\${merges}"; [ -z "\${merges}" ] |