From d97dc31bcd15e461a10835e65bba590efcfcce2b Mon Sep 17 00:00:00 2001 From: Calum MacRae Date: Tue, 30 Apr 2024 11:38:01 +0100 Subject: [PATCH] ci: sync `main` to `release` these changes implement a workflow to automatically sync changes pushed to the `main` branch to `release`. it does this with a rebase to maintain accurate commit history. in the event of a failed rebase (most likely a conflict), the workflow will raise a PR so that a human can intervene and resolve any conflicts. --- .github/workflows/sync-main-to-release.yaml | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/sync-main-to-release.yaml diff --git a/.github/workflows/sync-main-to-release.yaml b/.github/workflows/sync-main-to-release.yaml new file mode 100644 index 0000000..d6f8d2a --- /dev/null +++ b/.github/workflows/sync-main-to-release.yaml @@ -0,0 +1,40 @@ +name: sync 'main' branch to 'release' +on: + push: + branches: + - main + +permissions: write-all + +jobs: + sync-branches: + runs-on: ubuntu-latest + name: sync main to release + steps: + + - name: checkout 'release' + uses: actions/checkout@v4 + with: + ref: release + + - name: rebase onto 'main' + id: rebase + continue-on-error: true + run: | + git fetch origin main + git rebase origin/main + + - name: push changes to 'release' + if: success() && steps.rebase.outcome == 'success' + run: | + git push origin release --force-with-lease + + - name: open pr on rebase failure + id: pull + if: steps.rebase.outcome == 'failure' + uses: TreTuna/sync-branches@1.4.0 + with: + FROM_BRANCH: "main" + TO_BRANCH: "release" + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + PULL_REQUEST_TITLE: "chore: sync main -> release"