From d4636c2bb257b079eafb859c2ae58f84a317bd12 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Thu, 15 Oct 2026 11:04:04 -0700 Subject: [PATCH] Use shared branch synchronization action Co-authored-by: Codex --- .github/workflows/sync-dev-to-vX.Y-dev.yaml | 69 +++------------------ .github/workflows/sync-main-to-dev.yaml | 58 +++-------------- 2 files changed, 15 insertions(+), 112 deletions(-) diff --git a/.github/workflows/sync-dev-to-vX.Y-dev.yaml b/.github/workflows/sync-dev-to-vX.Y-dev.yaml index 26579009b1..2f7dd308ca 100644 --- a/.github/workflows/sync-dev-to-vX.Y-dev.yaml +++ b/.github/workflows/sync-dev-to-vX.Y-dev.yaml @@ -1,12 +1,8 @@ name: sync-dev-to-vX.Y-dev -# author: @ralfhandl +# Create PRs to update active version-development branches with shared changes +# from dev, then merge each PR after its required checks pass. -# -# This workflow creates PRs to update the vX.Y-dev branch with the latest changes from dev -# - -# run this on push to dev on: push: branches: @@ -18,60 +14,11 @@ jobs: if: github.repository == 'OAI/OpenAPI-Specification' runs-on: ubuntu-latest steps: - - name: Generate access token - id: generate-token - uses: actions/create-github-app-token@v3 + - name: Synchronize version branches with dev + uses: OAI/build-infra/actions/sync-branches@main with: - client-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} + app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }} - - - name: Checkout repository - uses: actions/checkout@v7 - 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} - 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/ - # exclude mjs files because we want to sync from the head - # neutralizes non-zero exit code because an empty selection result returns 1 - git checkout origin/$BASE -- tests/schema/ ':!*.mjs' || echo "" - # Preserve the destination branch's schema test runner. - git checkout "origin/$BASE" -- tests/schema/schema.test.mjs - git commit -m "Restored src/ and tests/schema/" || 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 $SYNC into $BASE" - continue - fi - - PR=$(gh pr create --base $BASE --head $SYNC \ - --label "Housekeeping" \ - --title "$BASE: sync with $HEAD" \ - --body "Merge relevant changes from \`$HEAD\` into \`$BASE\`.") - echo "" - echo "PR to sync $BASE with $HEAD: $PR" - sleep 60 # allow status checks to be triggered - - gh pr checks $PR --watch --required || continue - gh pr merge $PR --merge --admin - done - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - HEAD: dev + head: dev + base-pattern: '^v[0-9]+\.[0-9]+-dev$' + auto-merge: true diff --git a/.github/workflows/sync-main-to-dev.yaml b/.github/workflows/sync-main-to-dev.yaml index a49644d3df..d89e5a1542 100644 --- a/.github/workflows/sync-main-to-dev.yaml +++ b/.github/workflows/sync-main-to-dev.yaml @@ -1,12 +1,8 @@ name: sync-main-to-dev -# author: @ralfhandl +# Create a PR to update dev with shared changes from main. The build-infra +# action preserves paths listed in spec.config.json release.removeOnReleaseBranch. -# -# This workflow creates PRs to update the dev branch with the latest changes from main -# - -# run this on push to main on: push: branches: @@ -18,50 +14,10 @@ jobs: if: github.repository == 'OAI/OpenAPI-Specification' runs-on: ubuntu-latest steps: - - name: Generate access token - id: generate-token - uses: actions/create-github-app-token@v3 + - name: Synchronize dev with main + uses: OAI/build-infra/actions/sync-branches@main with: - client-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} + app-id: ${{ secrets.OAI_SPEC_PUBLISHER_APPID }} private-key: ${{ secrets.OAI_SPEC_PUBLISHER_PRIVATE_KEY }} - - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 0 - token: ${{ steps.generate-token.outputs.token }} - - - name: Create pull request - id: pull_request - shell: bash - run: | - 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/ - # exclude mjs files because we want to sync from the head - # neutralizes non-zero exit code because an empty selection result returns 1 - git checkout origin/$BASE -- tests/schema/ ':!*.mjs' || echo "" - # Preserve the destination branch's schema test runner. - git checkout "origin/$BASE" -- tests/schema/schema.test.mjs - git commit -m "Restored src/ and tests/schema/" || 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 $SYNC into $BASE" - exit 0 - fi - - gh pr create --base $BASE --head $SYNC \ - --label "Housekeeping" \ - --title "$BASE: sync with $HEAD" \ - --body "Merge relevant changes from \`$HEAD\` into \`$BASE\`." - env: - GH_TOKEN: ${{ steps.generate-token.outputs.token }} - HEAD: main - BASE: dev + head: main + base: dev