name: Rebase release_4.6-next and stable-2.6 on: push: branches: - release_4.6 workflow_dispatch: # Allows manual triggering of the workflow from the GitHub UI jobs: rebase: runs-on: ubuntu-latest permissions: contents: write strategy: matrix: target_branch: - release_4.6-next - stable-2.6 steps: - name: Checkout ${{ matrix.target_branch }} Branch uses: actions/checkout@v4 with: ref: ${{ matrix.target_branch }} token: ${{ secrets.GITHUB_TOKEN }} - name: Fetch release_4.6 Branch for ${{ matrix.target_branch }} run: git fetch origin release_4.6:release_4.6 - name: Attempt Rebase release_4.6 into ${{ matrix.target_branch }} id: rebase_attempt run: | git config user.name "GitHub Actions" git config user.email "github-actions[bot]@users.noreply.github.com" git checkout ${{ matrix.target_branch }} git rebase release_4.6 || true continue-on-error: true # Allow this step to fail without stopping the workflow immediately - name: Check for Conflicts and Abort if Necessary for ${{ matrix.target_branch }} run: | if git status --porcelain | grep "^UU"; then echo "::error::Rebase failed for ${{ matrix.target_branch }} due to merge conflicts. Aborting rebase." git rebase --abort exit 1 # Fail the job explicitly else echo "Rebase for ${{ matrix.target_branch }} completed without conflicts." fi - name: Force Push Rebased ${{ matrix.target_branch }} Branch if: success() && steps.rebase_attempt.outcome != 'failure' run: | git push --force origin ${{ matrix.target_branch }}