From cbe0cbd2a8671bc5733dc8ffd64b98522c565478 Mon Sep 17 00:00:00 2001 From: Egil Hansen Date: Fri, 12 Apr 2024 17:15:42 +0000 Subject: [PATCH] ci: add automatic rebase of v2 on main after push to main --- .github/workflows/rebase-v2-on-main.yml | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/rebase-v2-on-main.yml diff --git a/.github/workflows/rebase-v2-on-main.yml b/.github/workflows/rebase-v2-on-main.yml new file mode 100644 index 000000000..236edf253 --- /dev/null +++ b/.github/workflows/rebase-v2-on-main.yml @@ -0,0 +1,57 @@ +on: + push: + branches: + - main + + workflow_dispatch: + +env: + VSTEST_CONNECTION_TIMEOUT: 180 + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 + TERM: xterm + +jobs: + rebase: + name: 🎁 Rebase V2 on Main + runs-on: ubuntu-latest + steps: + + - name: 🛒 Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.BUNIT_BOT_TOKEN }} + + - name: ⚙️ Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.BUNIT_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.BUNIT_BOT_GPG_KEY_PASSPHRASE }} + + - name: ⚙️ Setup CI GIT + run: | + git config user.name "${{ steps.import_gpg.outputs.name }}" + git config user.email ${{ steps.import_gpg.outputs.email }} + git config --global user.signingkey ${{ steps.import_gpg.outputs.keyid }} + git config --global commit.gpgsign true + + - name: ⏩ Merge stable with main, push to origin + id: rebaseV2 + continue-on-error: true + run: | + git checkout v2 + git git rebase origin/main + git push origin v2 + + - name: ⏭ Create pull request from main to v2 when direct rebase fails + if: steps.rebaseV2.outcome == 'failure' + uses: thomaseizinger/create-pull-request@1.3.1 + env: + GITHUB_TOKEN: ${{ secrets.BUNIT_BOT_TOKEN }} + with: + head: main + base: v2 + title: Rebase v2 on main