-
Notifications
You must be signed in to change notification settings - Fork 12
80 lines (71 loc) · 2.49 KB
/
verify-codegen.yaml
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
# Copyright 2024 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow verifies that the generated files are in sync with API types.
name: Verify Codegen
on: [ push, pull_request ]
jobs:
regenerate-crds:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'GoogleCloudPlatform/gke-networking-api'
permissions:
contents: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
id: checkout
with:
ref: ${{ github.head_ref }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Run the update script
run: |
./hack/update-codegen.sh
id: update
- name: Check for changes
id: git_diff
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "::set-output name=has_changes::true"
else
echo "::set-output name=has_changes::false"
fi
- name: Commit changes
if: steps.git_diff.outputs.has_changes == 'true'
run: |
git config user.name 'gke-networking-gh-bot'
git config user.email '[email protected]'
git add .
git commit -m "[Auto-generated]: regenerate CRDs."
- name: Push changes
run: git push origin ${{ github.head_ref }}
run-verify-script:
runs-on: ubuntu-latest
needs: regenerate-crds
if: always() && (needs.regenerate-crds.result == 'success' || needs.regenerate-crds.result == 'skipped')
steps:
- name: Check out repository code
uses: actions/checkout@v4
id: checkout
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Run the verify script
run: |
./hack/verify-codegen.sh
id: verify