-
Notifications
You must be signed in to change notification settings - Fork 1
45 lines (38 loc) · 1.24 KB
/
verify-codegen.yml
File metadata and controls
45 lines (38 loc) · 1.24 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
name: Verify
on:
pull_request:
workflow_dispatch:
jobs:
verify:
name: Verify Codegen
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run Codegen
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make update-codegen
- name: Verify
shell: bash
run: |
# URL encode function for GitHub Actions annotations
# From: https://backreference.org/2009/12/23/how-to-match-newlines-in-sed/
function urlencode() {
sed ':begin;$!N;s/\n/%0A/;tbegin'
}
if [[ -z "$(git status --porcelain)" ]]; then
echo "${{ github.repository }} up to date."
else
echo "Found diffs in: $(git diff-index --name-only HEAD --)"
for x in $(git diff-index --name-only HEAD --); do
echo "::error file=$x::Please run 'make update-codegen'.%0A$(git diff $x | urlencode)"
done
echo "Generated code is out of date. Please run 'make update-codegen' and commit the changes."
exit 1
fi