From f60b80ad8c46ab9c8e808efb4fc23995c2eb1776 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sat, 4 Oct 2025 18:48:08 +0200 Subject: [PATCH] sync dev with main via sync branch - create sync branch from dev - merge main into sync branch - restore src/* and tests/* from dev - commit & push - create PR if necessary --- .github/workflows/sync-main-to-dev.yaml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync-main-to-dev.yaml b/.github/workflows/sync-main-to-dev.yaml index d480254da8..06ad0fdef4 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_ACTOR} + git config user.email "a@b.c" + 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