From 63d46be5765518062a8ba5e24016ac5059bbf5ba Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sun, 5 Oct 2025 11:59:07 +0200 Subject: [PATCH] sync main -> dev -> vX.Y-dev via sync branches Steps: - create sync branch from base branch - merge head branch into sync branch - restore src/* and tests/* from base branch - commit & push - create PR for merging sync branch into base branch --- .github/workflows/sync-dev-to-vX.Y-dev.yaml | 28 +++++++++++++++------ .github/workflows/sync-main-to-dev.yaml | 25 ++++++++++++++---- 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.github/workflows/sync-dev-to-vX.Y-dev.yaml b/.github/workflows/sync-dev-to-vX.Y-dev.yaml index 0ace68b375..3019659006 100644 --- a/.github/workflows/sync-dev-to-vX.Y-dev.yaml +++ b/.github/workflows/sync-dev-to-vX.Y-dev.yaml @@ -11,6 +11,7 @@ on: push: branches: - dev + workflow_dispatch: {} jobs: sync-branches: @@ -22,36 +23,49 @@ jobs: with: app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }} - + - name: Checkout repository uses: actions/checkout@v5 with: fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} - name: Create pull requests id: pull_requests shell: bash run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + DEV_BRANCHES=$(git branch -r --list origin/v?.?-dev) for DEV_BRANCH in $DEV_BRANCHES; do BASE=${DEV_BRANCH:7} - EXISTS=$(gh pr list --base $BASE --head $HEAD \ + SYNC="$BASE-sync-with-$HEAD" + + git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE + git merge origin/$HEAD -m "Merge $HEAD into $SYNC" + git checkout origin/$BASE src/* + git checkout origin/$BASE tests/* + git commit -m "Restored src/* and tests/*" || echo "" + git push -u origin $SYNC + + EXISTS=$(gh pr list --base $BASE --head $SYNC \ --json number --jq '.[] | .number') if [ ! -z "$EXISTS" ]; then - echo "PR #$EXISTS already wants to merge $HEAD into $BASE" + echo "PR #$EXISTS already wants to merge $SYNC into $BASE" continue fi - PR=$(gh pr create --base $BASE --head $HEAD \ + PR=$(gh pr create --base $BASE --head $SYNC \ --label "Housekeeping" \ - --title "$BASE: update from $HEAD" \ - --body "Merge \`$HEAD\` into \`$BASE\`.") + --title "$BASE: sync with $HEAD" \ + --body "Merge relevant changes from \`$HEAD\` into \`$BASE\`.") echo "" echo "PR to sync $DEV_BRANCH: $PR" sleep 10 # allow status checks to be triggered gh pr checks $PR --watch --required || continue - gh pr merge $PR --merge --admin + # gh pr merge $PR --merge --admin done env: GH_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/.github/workflows/sync-main-to-dev.yaml b/.github/workflows/sync-main-to-dev.yaml index d480254da8..09e1cd16e9 100644 --- a/.github/workflows/sync-main-to-dev.yaml +++ b/.github/workflows/sync-main-to-dev.yaml @@ -11,6 +11,7 @@ on: push: branches: - main + workflow_dispatch: {} jobs: sync-branch: @@ -25,22 +26,36 @@ jobs: - name: Checkout repository uses: actions/checkout@v5 + with: + fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} - name: Create pull request id: pull_request shell: bash run: | - EXISTS=$(gh pr list --base $BASE --head $HEAD \ + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + SYNC="$BASE-sync-with-$HEAD" + + git checkout -b $SYNC origin/$SYNC || git checkout -b $SYNC origin/$BASE + git merge origin/$HEAD -m "Merge $HEAD into $SYNC" + git checkout origin/$BASE src/* + git checkout origin/$BASE tests/* + git commit -m "Restored src/* and tests/*" || echo "" + git push -u origin $SYNC + + EXISTS=$(gh pr list --base $BASE --head $SYNC \ --json number --jq '.[] | .number') if [ ! -z "$EXISTS" ]; then - echo "PR #$EXISTS already wants to merge $HEAD into $BASE" + echo "PR #$EXISTS already wants to merge $SYNC into $BASE" exit 0 fi - gh pr create --base $BASE --head $HEAD \ + gh pr create --base $BASE --head $SYNC \ --label "Housekeeping" \ - --title "$BASE: update from $HEAD" \ - --body "Merge \`$HEAD\` into \`$BASE\`." + --title "$BASE: sync with $HEAD" \ + --body "Merge relevant changes from \`$HEAD\` into \`$BASE\`." env: GH_TOKEN: ${{ steps.generate-token.outputs.token }} HEAD: main