From d35cb248cb97f8f8a0d426af32c155eb6b4e6b57 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 12:39:51 -0400 Subject: [PATCH 1/7] build: [WIP] checkout and push instead of direct calls to GitHub API --- .github/workflows/generate.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 3961c0bddb8..2640777ad4a 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -41,18 +41,18 @@ jobs: pip install pip==21.3.1 pip --version - run: ./google-api-java-client-services/.github/workflows/generate.sh ${{ matrix.service }} - - uses: googleapis/code-suggester@v2 # takes the changes from git directory + - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 + token: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} + commit-message: ${{ env.MESSAGE }} + committer: ${{ env.AUTHOR }} + author: ${{ env.AUTHOR }} + branch: regenerate-${{ matrix.service }} + title: ${{ env.MESSAGE }} + body: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml' + add-paths: 'google-api-java-client-services/clients/google-api-services-${{ matrix.service }}' + base: main + push-to-fork: yoshi-code-bot/google-api-java-client-services + env: - ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} - with: - command: pr - upstream_owner: ${{ github.repository_owner }} - upstream_repo: google-api-java-client-services - description: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml' - title: 'chore: regenerate ${{ matrix.service }} client' - message: 'chore: regenerate ${{ matrix.service }} client' - branch: regenerate-${{ matrix.service }} - git_dir: 'google-api-java-client-services/clients/google-api-services-${{ matrix.service }}' - primary: main - force: true - fork: true + - MESSAGE: 'chore: regenerate ${{ matrix.service }} client' + - AUTHOR: Yoshi Code Bot From f177393e8957a2f489daccfcc53b1ae94ccf94a6 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 12:55:00 -0400 Subject: [PATCH 2/7] build: use this branch for testing --- .github/workflows/codegen.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codegen.yaml b/.github/workflows/codegen.yaml index dceaf457dbc..2ea31337b3e 100644 --- a/.github/workflows/codegen.yaml +++ b/.github/workflows/codegen.yaml @@ -56,7 +56,7 @@ jobs: } return result generate: - uses: googleapis/google-api-java-client-services/.github/workflows/generate.yaml@main + uses: googleapis/google-api-java-client-services/.github/workflows/generate.yaml@build/fix-compute needs: batch secrets: inherit # The size of the batch is implicitly decided by the hour of the day. From bb67a7238060a57c49d3ae44b753e2bee2d91510 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 13:01:26 -0400 Subject: [PATCH 3/7] fix: fix linter warnings --- .github/workflows/codegen.yaml | 4 ++-- .github/workflows/generate.yaml | 27 ++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/codegen.yaml b/.github/workflows/codegen.yaml index 2ea31337b3e..334b48ca010 100644 --- a/.github/workflows/codegen.yaml +++ b/.github/workflows/codegen.yaml @@ -56,12 +56,12 @@ jobs: } return result generate: - uses: googleapis/google-api-java-client-services/.github/workflows/generate.yaml@build/fix-compute + uses: googleapis/google-api-java-client-services/.github/workflows/generate.yaml@main needs: batch secrets: inherit # The size of the batch is implicitly decided by the hour of the day. # For example, a job starting at "1:30" uses the chunk at the index 1 in the array. - if: github.event_name != 'workflow_dispatch' && ${{!!fromJson(needs.batch.outputs.services).batches[fromJson(needs.batch.outputs.services).hour]}} + if: ${{ github.event_name != 'workflow_dispatch' && !!fromJson(needs.batch.outputs.services).batches[fromJson(needs.batch.outputs.services).hour] }} with: services: ${{toJson(fromJson(needs.batch.outputs.services).batches[fromJson(needs.batch.outputs.services).hour])}} generate_dispatch: diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 2640777ad4a..e85051fca91 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -42,17 +42,18 @@ jobs: pip --version - run: ./google-api-java-client-services/.github/workflows/generate.sh ${{ matrix.service }} - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 - token: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} - commit-message: ${{ env.MESSAGE }} - committer: ${{ env.AUTHOR }} - author: ${{ env.AUTHOR }} - branch: regenerate-${{ matrix.service }} - title: ${{ env.MESSAGE }} - body: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml' - add-paths: 'google-api-java-client-services/clients/google-api-services-${{ matrix.service }}' - base: main - push-to-fork: yoshi-code-bot/google-api-java-client-services - env: - - MESSAGE: 'chore: regenerate ${{ matrix.service }} client' - - AUTHOR: Yoshi Code Bot + MESSAGE: 'chore: regenerate ${{ matrix.service }} client' + AUTHOR: Yoshi Code Bot + with: + token: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} + commit-message: ${{ env.MESSAGE }} + committer: ${{ env.AUTHOR }} + author: ${{ env.AUTHOR }} + branch: regenerate-${{ matrix.service }} + title: ${{ env.MESSAGE }} + body: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml' + add-paths: 'google-api-java-client-services/clients/google-api-services-${{ matrix.service }}' + base: main + push-to-fork: yoshi-code-bot/google-api-java-client-services + From 96cbe77828d22a1d3f237b5fc583227fe5f5718c Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 13:06:56 -0400 Subject: [PATCH 4/7] build: inline bash script instead --- .github/workflows/generate.yaml | 59 ++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index e85051fca91..2cb1f1f34c8 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -41,19 +41,48 @@ jobs: pip install pip==21.3.1 pip --version - run: ./google-api-java-client-services/.github/workflows/generate.sh ${{ matrix.service }} - - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 + - name: Create PR via Local Checkout (Large Commit Support) + shell: bash env: - MESSAGE: 'chore: regenerate ${{ matrix.service }} client' - AUTHOR: Yoshi Code Bot - with: - token: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} - commit-message: ${{ env.MESSAGE }} - committer: ${{ env.AUTHOR }} - author: ${{ env.AUTHOR }} - branch: regenerate-${{ matrix.service }} - title: ${{ env.MESSAGE }} - body: 'Generated in GitHub action: https://github.com/${{ github.repository_owner }}/${{ github.repository }}/actions/workflows/codegen.yaml' - add-paths: 'google-api-java-client-services/clients/google-api-services-${{ matrix.service }}' - base: main - push-to-fork: yoshi-code-bot/google-api-java-client-services - + GH_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} + SERVICE: ${{ matrix.service }} + AUTHOR: "Yoshi Code Bot " + FORK_REPO: "yoshi-code-bot/google-api-java-client-services" + BASE_REPO: "${{ github.repository }}" + run: | + # 1. Setup Identity + git config user.name "Yoshi Code Bot" + git config user.email "yoshi-automation@google.com" + + # 2. Add and Fetch Fork + git remote add fork "https://x-access-token:${GH_TOKEN}@github.com/${FORK_REPO}.git" + + # 3. Create Branch + BRANCH="regenerate-${SERVICE}" + git checkout -b "$BRANCH" + + # 4. Stage specific files (Large commit handling) + TARGET_PATH="google-api-java-client-services/clients/google-api-services-${SERVICE}" + git add "$TARGET_PATH" + + # 5. Commit & Push + MESSAGE="chore: regenerate ${SERVICE} client" + if git diff-index --quiet HEAD --; then + echo "No changes to commit for ${SERVICE}." + exit 0 + fi + + git commit -m "$MESSAGE" + git push fork "$BRANCH" --force + + # 6. Create PR using GitHub CLI + # Note: --head needs 'owner:branch' format when pushing from a fork + FORK_OWNER=$(echo "$FORK_REPO" | cut -d'/' -f1) + + gh pr create \ + --repo "$BASE_REPO" \ + --head "${FORK_OWNER}:${BRANCH}" \ + --base "main" \ + --title "$MESSAGE" \ + --body "Generated in GitHub action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \ + || echo "PR already exists or failed to create, but changes are pushed." From 0c907b3505f172c442ca307518cfa3347abd6f6a Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 13:12:28 -0400 Subject: [PATCH 5/7] fix: cd into git repo --- .github/workflows/generate.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 2cb1f1f34c8..7effba1b4d1 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -43,6 +43,7 @@ jobs: - run: ./google-api-java-client-services/.github/workflows/generate.sh ${{ matrix.service }} - name: Create PR via Local Checkout (Large Commit Support) shell: bash + working-directory: google-api-java-client-services env: GH_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} SERVICE: ${{ matrix.service }} @@ -50,6 +51,8 @@ jobs: FORK_REPO: "yoshi-code-bot/google-api-java-client-services" BASE_REPO: "${{ github.repository }}" run: | + set -ex + # 1. Setup Identity git config user.name "Yoshi Code Bot" git config user.email "yoshi-automation@google.com" From 630375c41ed007fb81b94662b4b856dd9fdb1664 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 13:15:41 -0400 Subject: [PATCH 6/7] fix: do not use base folder for git add --- .github/workflows/generate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 7effba1b4d1..24f04fea11f 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -65,7 +65,7 @@ jobs: git checkout -b "$BRANCH" # 4. Stage specific files (Large commit handling) - TARGET_PATH="google-api-java-client-services/clients/google-api-services-${SERVICE}" + TARGET_PATH="clients/google-api-services-${SERVICE}" git add "$TARGET_PATH" # 5. Commit & Push From 210e8760f73afab6e1f547b479d78ce1bbe0e978 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Wed, 11 Mar 2026 13:25:54 -0400 Subject: [PATCH 7/7] fix: use cloud java bot --- .github/workflows/generate.yaml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/generate.yaml b/.github/workflows/generate.yaml index 24f04fea11f..75071bbaf11 100644 --- a/.github/workflows/generate.yaml +++ b/.github/workflows/generate.yaml @@ -27,6 +27,7 @@ jobs: with: fetch-depth: 1 path: google-api-java-client-services + token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }} - uses: actions/checkout@v2 with: repository: googleapis/discovery-artifact-manager @@ -45,20 +46,16 @@ jobs: shell: bash working-directory: google-api-java-client-services env: - GH_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }} SERVICE: ${{ matrix.service }} - AUTHOR: "Yoshi Code Bot " - FORK_REPO: "yoshi-code-bot/google-api-java-client-services" + AUTHOR: "Cloud Java Bot " BASE_REPO: "${{ github.repository }}" run: | set -ex # 1. Setup Identity - git config user.name "Yoshi Code Bot" - git config user.email "yoshi-automation@google.com" - - # 2. Add and Fetch Fork - git remote add fork "https://x-access-token:${GH_TOKEN}@github.com/${FORK_REPO}.git" + git config user.name "Cloud Java Bot" + git config user.email "cloud-java-bot@google.com" # 3. Create Branch BRANCH="regenerate-${SERVICE}" @@ -76,15 +73,11 @@ jobs: fi git commit -m "$MESSAGE" - git push fork "$BRANCH" --force - - # 6. Create PR using GitHub CLI - # Note: --head needs 'owner:branch' format when pushing from a fork - FORK_OWNER=$(echo "$FORK_REPO" | cut -d'/' -f1) + git push origin "$BRANCH" --force gh pr create \ --repo "$BASE_REPO" \ - --head "${FORK_OWNER}:${BRANCH}" \ + --head "${BRANCH}" \ --base "main" \ --title "$MESSAGE" \ --body "Generated in GitHub action: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \