From dc61e2159903bcfdddfaf19e6a887d8c4b1e115c Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Thu, 18 Jun 2026 10:01:04 -0400 Subject: [PATCH] ci(workflows): use librarian action for issue creation in regenerate-all --- .github/workflows/regenerate-all.yml | 56 ++++++++++------------------ 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/.github/workflows/regenerate-all.yml b/.github/workflows/regenerate-all.yml index 8f9d4af25376..21e6f0a35743 100644 --- a/.github/workflows/regenerate-all.yml +++ b/.github/workflows/regenerate-all.yml @@ -43,44 +43,28 @@ jobs: run: | PATH=$PATH:/tmp/pandoc/bin librarian generate -all -v - git diff --exit-code - - name: Create issue on diff - if: failure() - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Check for generated code changes run: | if [ -n "$(git status --porcelain)" ]; then - TITLE="Regeneration check found diff" - RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - DIFF_STAT=$(git diff --stat) - BODY="The post-submit [regeneration check]($RUN_URL) found a diff. + git status + echo "==================== GIT DIFF ====================" + git diff + echo "==================================================" + echo "Regeneration produced code changes! Please run 'librarian generate -all -v' to update the generated files." + exit 1 + fi - Diff summary: - \`\`\` - $DIFF_STAT - \`\`\`" + - name: Create issue if previous step fails + if: ${{ failure() }} + uses: googleapis/librarian/.github/actions/create-issue-on-failure@main + with: + title: "Regeneration failed" + body: | + The post-submit [regeneration check](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) failed. - EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number') - if [ -z "$EXISTING_ISSUE" ]; then - gh issue create --title "$TITLE" --body "$BODY" - else - echo "Issue #$EXISTING_ISSUE already exists, adding a comment." - gh issue comment "$EXISTING_ISSUE" --body "Another failure with diff occurred: $RUN_URL" - fi - fi - - name: Create issue on generation failure - if: failure() - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - TITLE="Regeneration failed" - RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - BODY="The post-submit [regeneration check]($RUN_URL) failed." - EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number') - if [ -z "$EXISTING_ISSUE" ]; then - gh issue create --title "$TITLE" --body "$BODY" - else - echo "Issue #$EXISTING_ISSUE already exists, adding a comment." - gh issue comment "$EXISTING_ISSUE" --body "Another regeneration failure occurred: $RUN_URL" - fi + Please investigate the failure. To keep the `main` branch healthy, please consider **reverting the triggering change** first. + + You can identify the cause from the workflow logs: + - If the step 'Check for generated code changes' failed, there are pending code changes that need to be committed. + - If the step 'Regenerate' failed, the generation script itself encountered an error.