-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Add workflow to enforce rebase before merge
- Loading branch information
Xavier Chapron
committed
Dec 21, 2023
1 parent
86e20d8
commit f24934e
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
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
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}" ] |