Skip to content

CI: Add workflow to enforce rebase before merge #11

CI: Add workflow to enforce rebase before merge

CI: Add workflow to enforce rebase before merge #11

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: Show git log
shell: bash
run: |
git log
- name: Check if branch is up-to-date
shell: bash
run: |
git merge-base --is-ancestor ${{ github.event.pull_request.base.sha }} HEAD
- name: Check for merge commits
shell: bash
run: |
merges=$(git log --oneline HEAD~${{ github.event.pull_request.commits }}...HEAD --merges ); \
echo "--- Merges ---\n${merges}"; \
[ -z "${merges}" ]