From 4254d92f89e71b7947b7584a1bea0d5f9252ed75 Mon Sep 17 00:00:00 2001 From: Mo King Date: Fri, 24 Apr 2026 11:11:52 -0400 Subject: [PATCH] chore: reuse open sync PR instead of opening a new one each run Use a fixed sync-openapi branch with a force-push and only create a PR when one isn't already open, so repeated openapi.yaml changes update the existing PR in mintlify-docs instead of stacking new ones. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../workflows/sync-openapi-spec-to-docs.yml | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sync-openapi-spec-to-docs.yml b/.github/workflows/sync-openapi-spec-to-docs.yml index 53e5cc5..9e35803 100644 --- a/.github/workflows/sync-openapi-spec-to-docs.yml +++ b/.github/workflows/sync-openapi-spec-to-docs.yml @@ -42,16 +42,22 @@ jobs: exit 0 fi - BRANCH_NAME=sync-openapi-$(date +%s) + BRANCH_NAME=sync-openapi git checkout -b "$BRANCH_NAME" git add openapi.yaml git commit -m "Sync OpenAPI spec" - git push origin "$BRANCH_NAME" - - gh pr create \ - --title "Sync OpenAPI spec" \ - --body "This PR syncs the openapi.yaml from the togethercomputer/openapi repository." \ - --base main \ - --head "$BRANCH_NAME" \ - --assignee ryanto,zainhas,Nutlope + git push --force origin "$BRANCH_NAME" + + EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json number --jq '.[0].number') + + if [ -n "$EXISTING_PR" ]; then + echo "Updated existing PR #$EXISTING_PR" + else + gh pr create \ + --title "Sync OpenAPI spec" \ + --body "This PR syncs the openapi.yaml from the togethercomputer/openapi repository." \ + --base main \ + --head "$BRANCH_NAME" \ + --assignee ryanto,zainhas,Nutlope,muhsinking + fi