From 6f68df08b55c0fb0b19e3013ea5675e4c0fad3aa Mon Sep 17 00:00:00 2001 From: RohithSangati Date: Fri, 1 May 2026 19:00:56 +0530 Subject: [PATCH 1/4] moved pr title to env --- .github/workflows/python-client-gen.yml | 170 +++++++++++++----------- 1 file changed, 92 insertions(+), 78 deletions(-) diff --git a/.github/workflows/python-client-gen.yml b/.github/workflows/python-client-gen.yml index dc9ac126..f67a43a4 100644 --- a/.github/workflows/python-client-gen.yml +++ b/.github/workflows/python-client-gen.yml @@ -6,9 +6,17 @@ on: description: "The short commit sha that triggered the workflow" required: true type: string + # TEST: temporary push trigger so the workflow runs on this branch. + # Remove before merging. + push: + branches: + - hotfix/APICLI-3534 env: - NEW_BRANCH: openapi-${{ github.event.inputs.openapi_short_sha }}/clientgen + # TEST: hardcoded SHA used when triggered by push (no inputs available). + # Remove / revert before merging. + TEST_SHA: 6cafc08 + NEW_BRANCH: openapi-6cafc08/clientgen jobs: Generate-Python-Client: @@ -17,95 +25,101 @@ jobs: steps: - uses: actions/checkout@v3 - - name: OpenAPI Changelist - env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - run: | - current_sha=$(cat DO_OPENAPI_COMMIT_SHA.txt) - echo "current_sha=$current_sha" >> $GITHUB_ENV - target_sha=${{ github.event.inputs.openapi_short_sha }} - scripts/openapi_changelist.sh $current_sha $target_sha > changelist.md - - - name: Removes all generated code - run: make clean - - - name: Download spec file and Update DO_OPENAPI_COMMIT_SHA.txt - run: | - curl --fail https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/DigitalOcean-public-${{ github.event.inputs.openapi_short_sha }}.v2.yaml -o DigitalOcean-public.v2.yaml - echo ${{ github.event.inputs.openapi_short_sha }} > DO_OPENAPI_COMMIT_SHA.txt - env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - - uses: actions/upload-artifact@v4 - with: - name: DigitalOcean-public.v2 - path: ./DigitalOcean-public.v2.yaml - - - name: Checkout new Branch - run: git checkout -b ${{ env.NEW_BRANCH }} - env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - - name: Install Poetry - uses: snok/install-poetry@v1.3.4 - with: - version: 1.6.1 - virtualenvs-path: .venv - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: false - - - name: Generate Python client - run: make generate - - - name: Generate Python client documentation - run: make generate-docs - - - name: Add and commit changes - id: add-commit-changes - continue-on-error: true - run: | - git config --global user.email "api-engineering@digitalocean.com" - git config --global user.name "API Engineering" - git add . - git commit -m "[bot] Updated client based on ${{ env.NEW_BRANCH }}" - git push --set-upstream origin ${{ env.NEW_BRANCH }} - env: - GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - - name: Check if branch existed - # If steps.create-pr was anything but successful, it's possible that - # the branch was created in previous pipeline runs so it should be manually deleted. - if: steps.add-commit-changes.outcome != 'success' - run: | - echo "Add and commit changes step failed. It's possible the branch ${{ env.NEW_BRANCH }} already existed. Please delete the branch and re-run the pipeline." - exit 1 - + # ===== TEST: steps below are commented out for PR_TITLE testing. Restore before merging. ===== + # - name: OpenAPI Changelist + # env: + # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + # run: | + # current_sha=$(cat DO_OPENAPI_COMMIT_SHA.txt) + # echo "current_sha=$current_sha" >> $GITHUB_ENV + # target_sha=${{ github.event.inputs.openapi_short_sha }} + # scripts/openapi_changelist.sh $current_sha $target_sha > changelist.md + + - name: Stub changelist.md (TEST ONLY) + run: echo "_stub changelist content for testing_" > changelist.md + + # - name: Removes all generated code + # run: make clean + + # - name: Download spec file and Update DO_OPENAPI_COMMIT_SHA.txt + # run: | + # curl --fail https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/DigitalOcean-public-${{ github.event.inputs.openapi_short_sha }}.v2.yaml -o DigitalOcean-public.v2.yaml + # echo ${{ github.event.inputs.openapi_short_sha }} > DO_OPENAPI_COMMIT_SHA.txt + # env: + # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + # - uses: actions/upload-artifact@v4 + # with: + # name: DigitalOcean-public.v2 + # path: ./DigitalOcean-public.v2.yaml + + # - name: Checkout new Branch + # run: git checkout -b ${{ env.NEW_BRANCH }} + # env: + # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + # - name: Install Poetry + # uses: snok/install-poetry@v1.3.4 + # with: + # version: 1.6.1 + # virtualenvs-path: .venv + # virtualenvs-create: true + # virtualenvs-in-project: true + # installer-parallel: false + + # - name: Generate Python client + # run: make generate + + # - name: Generate Python client documentation + # run: make generate-docs + + # - name: Add and commit changes + # id: add-commit-changes + # continue-on-error: true + # run: | + # git config --global user.email "api-engineering@digitalocean.com" + # git config --global user.name "API Engineering" + # git add . + # git commit -m "[bot] Updated client based on ${{ env.NEW_BRANCH }}" + # git push --set-upstream origin ${{ env.NEW_BRANCH }} + # env: + # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + # - name: Check if branch existed + # # If steps.create-pr was anything but successful, it's possible that + # # the branch was created in previous pipeline runs so it should be manually deleted. + # if: steps.add-commit-changes.outcome != 'success' + # run: | + # echo "Add and commit changes step failed. It's possible the branch ${{ env.NEW_BRANCH }} already existed. Please delete the branch and re-run the pipeline." + # exit 1 + # ===== TEST: end of commented-out section ===== + + # ===== STEPS UNDER TEST ===== - name: Set pr_title outputs id: pr_title_var - run: echo "PR_TITLE=$(gh pr list --search "${{ github.event.inputs.openapi_short_sha }}" --json title --jq '.[0].title' --repo digitalocean/openapi --state merged)" >> $GITHUB_OUTPUT + # TEST: using ${{ env.TEST_SHA }} instead of github.event.inputs.openapi_short_sha + run: echo "PR_TITLE=$(gh pr list --search "${{ env.TEST_SHA }}" --json title --jq '.[0].title' --repo digitalocean/openapi --state merged)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check pr_title outputs - run: echo "${{ steps.pr_title_var.outputs.PR_TITLE }}" + run: echo "PR_TITLE from env=[$PR_TITLE]" + env: + PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} - - name: Create Pull Request + - name: Create Pull Request (DRY RUN) id: create-pr - if: steps.add-commit-changes.outcome == 'success' + # TEST: gate removed (add-commit-changes is disabled), gh pr create replaced with echo run: | export CURRENT="$(cat DO_OPENAPI_COMMIT_SHA.txt)" - export TARGET="${{ github.event.inputs.openapi_short_sha }}" - export TITLE="${{ steps.pr_title_var.outputs.PR_TITLE }}" + export TARGET="${{ env.TEST_SHA }}" + export TITLE="$PR_TITLE" envsubst < scripts/pr_body.md_tmpl > pr_body.md cat changelist.md >> pr_body.md - echo "PR BODY:" + echo "===== Final --title would be =====" + echo "[bot] $TITLE: Re-Generated From digitalocean/openapi@$TARGET" + echo "===== Final --body-file would be =====" cat pr_body.md - - gh pr create \ - --title "[bot] $TITLE: Re-Generated From digitalocean/openapi@$TARGET" \ - --body-file pr_body.md \ - --head "${{ env.NEW_BRANCH }}" \ - -r digitalocean/api-cli env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} From 5311794d5a5ce0acee35b76cd68a6cda9e259d50 Mon Sep 17 00:00:00 2001 From: RohithSangati Date: Fri, 1 May 2026 19:03:54 +0530 Subject: [PATCH 2/4] changes --- .github/workflows/python-client-gen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-client-gen.yml b/.github/workflows/python-client-gen.yml index f67a43a4..ea412e60 100644 --- a/.github/workflows/python-client-gen.yml +++ b/.github/workflows/python-client-gen.yml @@ -122,4 +122,4 @@ jobs: cat pr_body.md env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} + # PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} From adc07c8c17810ed3ba075e39f2781c18a85b42c4 Mon Sep 17 00:00:00 2001 From: RohithSangati Date: Fri, 1 May 2026 19:08:37 +0530 Subject: [PATCH 3/4] changes --- .github/workflows/python-client-gen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-client-gen.yml b/.github/workflows/python-client-gen.yml index ea412e60..adf07e92 100644 --- a/.github/workflows/python-client-gen.yml +++ b/.github/workflows/python-client-gen.yml @@ -112,7 +112,7 @@ jobs: run: | export CURRENT="$(cat DO_OPENAPI_COMMIT_SHA.txt)" export TARGET="${{ env.TEST_SHA }}" - export TITLE="$PR_TITLE" + export TITLE="${{ steps.pr_title_var.outputs.PR_TITLE }}" envsubst < scripts/pr_body.md_tmpl > pr_body.md cat changelist.md >> pr_body.md From 0b83b72d6cde315386daf4ffa41db130e2d694be Mon Sep 17 00:00:00 2001 From: RohithSangati Date: Fri, 1 May 2026 19:40:03 +0530 Subject: [PATCH 4/4] changes --- .github/workflows/python-client-gen.yml | 169 +++++++++++------------- 1 file changed, 79 insertions(+), 90 deletions(-) diff --git a/.github/workflows/python-client-gen.yml b/.github/workflows/python-client-gen.yml index adf07e92..99f117c7 100644 --- a/.github/workflows/python-client-gen.yml +++ b/.github/workflows/python-client-gen.yml @@ -6,17 +6,9 @@ on: description: "The short commit sha that triggered the workflow" required: true type: string - # TEST: temporary push trigger so the workflow runs on this branch. - # Remove before merging. - push: - branches: - - hotfix/APICLI-3534 env: - # TEST: hardcoded SHA used when triggered by push (no inputs available). - # Remove / revert before merging. - TEST_SHA: 6cafc08 - NEW_BRANCH: openapi-6cafc08/clientgen + NEW_BRANCH: openapi-${{ github.event.inputs.openapi_short_sha }}/clientgen jobs: Generate-Python-Client: @@ -25,101 +17,98 @@ jobs: steps: - uses: actions/checkout@v3 - # ===== TEST: steps below are commented out for PR_TITLE testing. Restore before merging. ===== - # - name: OpenAPI Changelist - # env: - # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - # run: | - # current_sha=$(cat DO_OPENAPI_COMMIT_SHA.txt) - # echo "current_sha=$current_sha" >> $GITHUB_ENV - # target_sha=${{ github.event.inputs.openapi_short_sha }} - # scripts/openapi_changelist.sh $current_sha $target_sha > changelist.md - - - name: Stub changelist.md (TEST ONLY) - run: echo "_stub changelist content for testing_" > changelist.md - - # - name: Removes all generated code - # run: make clean - - # - name: Download spec file and Update DO_OPENAPI_COMMIT_SHA.txt - # run: | - # curl --fail https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/DigitalOcean-public-${{ github.event.inputs.openapi_short_sha }}.v2.yaml -o DigitalOcean-public.v2.yaml - # echo ${{ github.event.inputs.openapi_short_sha }} > DO_OPENAPI_COMMIT_SHA.txt - # env: - # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - # - uses: actions/upload-artifact@v4 - # with: - # name: DigitalOcean-public.v2 - # path: ./DigitalOcean-public.v2.yaml - - # - name: Checkout new Branch - # run: git checkout -b ${{ env.NEW_BRANCH }} - # env: - # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - # - name: Install Poetry - # uses: snok/install-poetry@v1.3.4 - # with: - # version: 1.6.1 - # virtualenvs-path: .venv - # virtualenvs-create: true - # virtualenvs-in-project: true - # installer-parallel: false - - # - name: Generate Python client - # run: make generate - - # - name: Generate Python client documentation - # run: make generate-docs - - # - name: Add and commit changes - # id: add-commit-changes - # continue-on-error: true - # run: | - # git config --global user.email "api-engineering@digitalocean.com" - # git config --global user.name "API Engineering" - # git add . - # git commit -m "[bot] Updated client based on ${{ env.NEW_BRANCH }}" - # git push --set-upstream origin ${{ env.NEW_BRANCH }} - # env: - # GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - - # - name: Check if branch existed - # # If steps.create-pr was anything but successful, it's possible that - # # the branch was created in previous pipeline runs so it should be manually deleted. - # if: steps.add-commit-changes.outcome != 'success' - # run: | - # echo "Add and commit changes step failed. It's possible the branch ${{ env.NEW_BRANCH }} already existed. Please delete the branch and re-run the pipeline." - # exit 1 - # ===== TEST: end of commented-out section ===== - - # ===== STEPS UNDER TEST ===== + - name: OpenAPI Changelist + env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + run: | + current_sha=$(cat DO_OPENAPI_COMMIT_SHA.txt) + echo "current_sha=$current_sha" >> $GITHUB_ENV + target_sha=${{ github.event.inputs.openapi_short_sha }} + scripts/openapi_changelist.sh $current_sha $target_sha > changelist.md + + - name: Removes all generated code + run: make clean + + - name: Download spec file and Update DO_OPENAPI_COMMIT_SHA.txt + run: | + curl --fail https://api-engineering.nyc3.digitaloceanspaces.com/spec-ci/DigitalOcean-public-${{ github.event.inputs.openapi_short_sha }}.v2.yaml -o DigitalOcean-public.v2.yaml + echo ${{ github.event.inputs.openapi_short_sha }} > DO_OPENAPI_COMMIT_SHA.txt + env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + - uses: actions/upload-artifact@v4 + with: + name: DigitalOcean-public.v2 + path: ./DigitalOcean-public.v2.yaml + + - name: Checkout new Branch + run: git checkout -b ${{ env.NEW_BRANCH }} + env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + - name: Install Poetry + uses: snok/install-poetry@v1.3.4 + with: + version: 1.6.1 + virtualenvs-path: .venv + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: false + + - name: Generate Python client + run: make generate + + - name: Generate Python client documentation + run: make generate-docs + + - name: Add and commit changes + id: add-commit-changes + continue-on-error: true + run: | + git config --global user.email "api-engineering@digitalocean.com" + git config --global user.name "API Engineering" + git add . + git commit -m "[bot] Updated client based on ${{ env.NEW_BRANCH }}" + git push --set-upstream origin ${{ env.NEW_BRANCH }} + env: + GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} + + - name: Check if branch existed + # If steps.create-pr was anything but successful, it's possible that + # the branch was created in previous pipeline runs so it should be manually deleted. + if: steps.add-commit-changes.outcome != 'success' + run: | + echo "Add and commit changes step failed. It's possible the branch ${{ env.NEW_BRANCH }} already existed. Please delete the branch and re-run the pipeline." + exit 1 + - name: Set pr_title outputs id: pr_title_var - # TEST: using ${{ env.TEST_SHA }} instead of github.event.inputs.openapi_short_sha - run: echo "PR_TITLE=$(gh pr list --search "${{ env.TEST_SHA }}" --json title --jq '.[0].title' --repo digitalocean/openapi --state merged)" >> $GITHUB_OUTPUT + run: echo "PR_TITLE=$(gh pr list --search "${{ github.event.inputs.openapi_short_sha }}" --json title --jq '.[0].title' --repo digitalocean/openapi --state merged)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check pr_title outputs - run: echo "PR_TITLE from env=[$PR_TITLE]" + run: echo "$PR_TITLE" env: PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} - - name: Create Pull Request (DRY RUN) + - name: Create Pull Request id: create-pr - # TEST: gate removed (add-commit-changes is disabled), gh pr create replaced with echo + if: steps.add-commit-changes.outcome == 'success' run: | export CURRENT="$(cat DO_OPENAPI_COMMIT_SHA.txt)" - export TARGET="${{ env.TEST_SHA }}" - export TITLE="${{ steps.pr_title_var.outputs.PR_TITLE }}" + export TARGET="${{ github.event.inputs.openapi_short_sha }}" + export TITLE="$PR_TITLE" envsubst < scripts/pr_body.md_tmpl > pr_body.md cat changelist.md >> pr_body.md - echo "===== Final --title would be =====" - echo "[bot] $TITLE: Re-Generated From digitalocean/openapi@$TARGET" - echo "===== Final --body-file would be =====" + echo "PR BODY:" cat pr_body.md + + gh pr create \ + --title "[bot] $TITLE: Re-Generated From digitalocean/openapi@$TARGET" \ + --body-file pr_body.md \ + --head "${{ env.NEW_BRANCH }}" \ + -r digitalocean/api-cli env: GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} - # PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }} + PR_TITLE: ${{ steps.pr_title_var.outputs.PR_TITLE }}