diff --git a/.github/workflows/force-rebase.yml b/.github/workflows/force-rebase.yml new file mode 100644 index 000000000..8d53e94f3 --- /dev/null +++ b/.github/workflows/force-rebase.yml @@ -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}" ]