-
Notifications
You must be signed in to change notification settings - Fork 1.7k
86 lines (74 loc) · 3.09 KB
/
Copy pathregenerate-all.yml
File metadata and controls
86 lines (74 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Regenerate all packages after merging to main
on:
push:
branches:
- main
permissions:
contents: read
issues: write
jobs:
regenerate:
runs-on: ubuntu-latest
env:
PANDOC_VERSION: 3.8.2
SYNTHTOOL_TEMPLATES: /home/runner/synthtool/synthtool/gcp/templates
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: googleapis/librarian@main
with:
protoc-version: "25.3"
protoc-checksum: "5ec3474ca09df0511bb2ca66b5ca091fa8943c30aa26285f225d0b1ba60b5665b3419be4cd2322decbb55464039ca0a0405a47e86bcc11491589405d615d280e"
- name: Install pandoc
run: |
mkdir /tmp/pandoc
curl -fsSL --retry 5 --retry-delay 15 -o /tmp/pandoc.tar.gz \
https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz
tar -xvf /tmp/pandoc.tar.gz -C /tmp/pandoc --strip-components=1
- name: Install Python packages for Librarian
run: librarian install
- name: Clone Synthtool Templates
run: |
git clone --recurse-submodules --single-branch https://github.com/googleapis/synthtool.git /home/runner/synthtool
- name: Regenerate
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 }}
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.
Diff summary:
\`\`\`
$DIFF_STAT
\`\`\`"
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