Skip to content

Commit 5b2264a

Browse files
authored
chore: use CLOUD_JAVA_BOT_GITHUB_TOKEN in readme workflow (#14751)
Update `.github/workflows/readme.yaml` to push the `update-readme` branch directly and open the PR using `CLOUD_JAVA_BOT_GITHUB_TOKEN` instead of `googleapis/code-suggester` with `YOSHI_CODE_BOT_TOKEN` (which fails with a 500 `HttpError` when syncing the fork). Note: This matches the existing PR creation pattern in [`java-cloud-bom-update-readme-table.yaml`](https://github.com/googleapis/google-cloud-java/blob/00f7bea135eb77de710e71c97ae5be3a2829886d/.github/workflows/java-cloud-bom-update-readme-table.yaml#L50-L63) and [`update_librarian_googleapis.yaml`](https://github.com/googleapis/google-cloud-java/blob/00f7bea135eb77de710e71c97ae5be3a2829886d/.github/workflows/update_librarian_googleapis.yaml#L132-L186). b/577077828
1 parent a993026 commit 5b2264a

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

‎.github/workflows/readme.yaml‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
update:
2626
runs-on: ubuntu-latest
2727
if: github.repository_owner == 'googleapis'
28+
permissions:
29+
contents: write
30+
pull-requests: write
2831
steps:
2932
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
3033
with:
@@ -35,17 +38,24 @@ jobs:
3538
architecture: 'x64'
3639
- run: python3 -m pip install --require-hashes -r .github/requirements.txt
3740
- run: python3 generate-readme.py
38-
- uses: googleapis/code-suggester@589b3ac11ac2575fd561afa45034907f301a375b # v4
41+
- name: Commit and Create PR
3942
env:
40-
ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
41-
with:
42-
command: pr
43-
upstream_owner: googleapis
44-
upstream_repo: google-cloud-java
45-
description: 'ran python3 generate-readme.py'
46-
title: 'chore: regenerate client table in README'
47-
message: 'chore: regenerate client table in README'
48-
branch: update-readme
49-
primary: main
50-
force: true
51-
git_dir: '.'
43+
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
44+
run: |
45+
git add README.md
46+
if git diff --cached --quiet; then
47+
echo "No changes in README.md"
48+
exit 0
49+
fi
50+
git config user.email "cloud-java-bot@google.com"
51+
git config user.name "Cloud Java Bot"
52+
git checkout -B update-readme
53+
git commit -m "chore: regenerate client table in README"
54+
git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git
55+
git push -f origin update-readme
56+
pr_num=$(gh pr list -s open -H update-readme --json number --jq '.[0].number // empty')
57+
if [ -z "${pr_num}" ]; then
58+
gh pr create --base main --head update-readme --title "chore: regenerate client table in README" --body "ran python3 generate-readme.py"
59+
else
60+
echo "Updated existing PR #${pr_num}"
61+
fi

0 commit comments

Comments
 (0)