Skip to content

CI: Add workflow to enforce rebase before merge #7

CI: Add workflow to enforce rebase before merge

CI: Add workflow to enforce rebase before merge #7

Workflow file for this run

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}" ]