|
| 1 | +name: Regenerate all packages after merging to main |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + regenerate: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + env: |
| 16 | + PANDOC_VERSION: 3.8.2 |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v6 |
| 21 | + |
| 22 | + - name: Install Go |
| 23 | + uses: actions/setup-go@v6 |
| 24 | + with: |
| 25 | + go-version: '1.26.x' |
| 26 | + |
| 27 | + - name: Install protoc |
| 28 | + uses: arduino/setup-protoc@v3 |
| 29 | + with: |
| 30 | + version: "25.3" |
| 31 | + |
| 32 | + - name: Install pandoc |
| 33 | + run: | |
| 34 | + mkdir /tmp/pandoc |
| 35 | + curl -fsSL --retry 5 --retry-delay 15 -o /tmp/pandoc.tar.gz \ |
| 36 | + https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz |
| 37 | + tar -xvf /tmp/pandoc.tar.gz -C /tmp/pandoc --strip-components=1 |
| 38 | +
|
| 39 | + - name: Install Python packages for Librarian |
| 40 | + run: | |
| 41 | + version=$(sed -n 's/^version: *//p' librarian.yaml) |
| 42 | + go run "github.com/googleapis/librarian/cmd/librarian@${version}" install |
| 43 | +
|
| 44 | + - name: Regenerate |
| 45 | + run: | |
| 46 | + version=$(sed -n 's/^version: *//p' librarian.yaml) |
| 47 | + PATH=$PATH:/tmp/pandoc/bin |
| 48 | + go run "github.com/googleapis/librarian/cmd/librarian@${version}" generate -all -v |
| 49 | +
|
| 50 | + - name: Create issue on diff |
| 51 | + env: |
| 52 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + run: | |
| 54 | + if [ -n "$(git status --porcelain)" ]; then |
| 55 | + TITLE="Regeneration check found diff" |
| 56 | + RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 57 | + DIFF_STAT=$(git diff --stat) |
| 58 | + BODY="The post-submit [regeneration check]($RUN_URL) found a diff. |
| 59 | +
|
| 60 | + Diff summary: |
| 61 | + \`\`\` |
| 62 | + $DIFF_STAT |
| 63 | + \`\`\`" |
| 64 | +
|
| 65 | + EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number') |
| 66 | + if [ -z "$EXISTING_ISSUE" ]; then |
| 67 | + gh issue create --title "$TITLE" --body "$BODY" |
| 68 | + else |
| 69 | + echo "Issue #$EXISTING_ISSUE already exists, adding a comment." |
| 70 | + gh issue comment "$EXISTING_ISSUE" --body "Another failure with diff occurred: $RUN_URL" |
| 71 | + fi |
| 72 | + fi |
| 73 | + - name: Create issue on generation failure |
| 74 | + if: failure() |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + run: | |
| 78 | + TITLE="Regeneration failed" |
| 79 | + RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 80 | + BODY="The post-submit [regeneration check]($RUN_URL) failed." |
| 81 | + EXISTING_ISSUE=$(gh issue list --state open --search "in:title \"$TITLE\"" --json number --jq '.[0].number') |
| 82 | + if [ -z "$EXISTING_ISSUE" ]; then |
| 83 | + gh issue create --title "$TITLE" --body "$BODY" |
| 84 | + else |
| 85 | + echo "Issue #$EXISTING_ISSUE already exists, adding a comment." |
| 86 | + gh issue comment "$EXISTING_ISSUE" --body "Another regeneration failure occurred: $RUN_URL" |
| 87 | + fi |
0 commit comments