Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PR must fail when generated code is not committed #704

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/generated-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Generate code and open pull request

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
Expand All @@ -27,7 +28,13 @@ jobs:
diff=$(git --no-pager diff --name-only HEAD)
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
## Run if diff exists and pull request, and make CI status failure
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
run: |
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2
exit 1
## Run if diff exists and event is not pull request, and make PR
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
Expand Down