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 9fe355d commit b7c5b1e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/force-rebase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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}" ]

0 comments on commit b7c5b1e

Please sign in to comment.