Merge pull request #48 from shouri007/main #159
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |