Skip to content

Commit

Permalink
CI: Add workflow to enforce rebase before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Chapron committed Dec 21, 2023
1 parent 86e20d8 commit 676867b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/force-rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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?
run: |
merges="\$(git log --oneline HEAD^${{ env.PR_FETCH_DEPTH }}...HEAD --merges )"; \
echo "--- Merges ---\\n\${merges}"; [ -z "\${merges}" ]

0 comments on commit 676867b

Please sign in to comment.