Skip to content

Commit 36255ad

Browse files
authored
ci(workflows): use librarian action for issue creation in regenerate-all (#17506)
Refactor regenerate-all workflow to use `create-issue-on-failure` action from librarian to create and assign issue. Replaces manual github-cli script steps with the shared `googleapis/librarian/.github/actions/create-issue-on-failure` action. Splits the regeneration execution and diff check into separate steps so it is easier to read from GHA log. Context: #17426 and #17427 was created on code generation diff/failures but was left unattended. This change will create issue with assignee to last committer and add ":rotating_light: critical" label to it. For googleapis/librarian#6450
1 parent 03d0574 commit 36255ad

1 file changed

Lines changed: 20 additions & 36 deletions

File tree

.github/workflows/regenerate-all.yml

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,44 +43,28 @@ jobs:
4343
run: |
4444
PATH=$PATH:/tmp/pandoc/bin
4545
librarian generate -all -v
46-
git diff --exit-code
4746
48-
- name: Create issue on diff
49-
if: failure()
50-
env:
51-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
- name: Check for generated code changes
5248
run: |
5349
if [ -n "$(git status --porcelain)" ]; then
54-
TITLE="Regeneration check found diff"
55-
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
56-
DIFF_STAT=$(git diff --stat)
57-
BODY="The post-submit [regeneration check]($RUN_URL) found a diff.
50+
git status
51+
echo "==================== GIT DIFF ===================="
52+
git diff
53+
echo "=================================================="
54+
echo "Regeneration produced code changes! Please run 'librarian generate -all -v' to update the generated files."
55+
exit 1
56+
fi
5857
59-
Diff summary:
60-
\`\`\`
61-
$DIFF_STAT
62-
\`\`\`"
58+
- name: Create issue if previous step fails
59+
if: ${{ failure() }}
60+
uses: googleapis/librarian/.github/actions/create-issue-on-failure@main
61+
with:
62+
title: "Regeneration failed"
63+
body: |
64+
The post-submit [regeneration check](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) failed.
6365
64-
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
65-
if [ -z "$EXISTING_ISSUE" ]; then
66-
gh issue create --title "$TITLE" --body "$BODY"
67-
else
68-
echo "Issue #$EXISTING_ISSUE already exists, adding a comment."
69-
gh issue comment "$EXISTING_ISSUE" --body "Another failure with diff occurred: $RUN_URL"
70-
fi
71-
fi
72-
- name: Create issue on generation failure
73-
if: failure()
74-
env:
75-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76-
run: |
77-
TITLE="Regeneration failed"
78-
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
79-
BODY="The post-submit [regeneration check]($RUN_URL) failed."
80-
EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number')
81-
if [ -z "$EXISTING_ISSUE" ]; then
82-
gh issue create --title "$TITLE" --body "$BODY"
83-
else
84-
echo "Issue #$EXISTING_ISSUE already exists, adding a comment."
85-
gh issue comment "$EXISTING_ISSUE" --body "Another regeneration failure occurred: $RUN_URL"
86-
fi
66+
Please investigate the failure. To keep the `main` branch healthy, please consider **reverting the triggering change** first.
67+
68+
You can identify the cause from the workflow logs:
69+
- If the step 'Check for generated code changes' failed, there are pending code changes that need to be committed.
70+
- If the step 'Regenerate' failed, the generation script itself encountered an error.

0 commit comments

Comments
 (0)