Skip to content

Commit

Permalink
PR must fail when generated code is not committed (#504)
Browse files Browse the repository at this point in the history
* NO-ISSUE PR must fail when generated code is not committed

* NO-ISSUE test

* NO-ISSUE Revert "NO-ISSUE test"

This reverts commit 88d3b44.
  • Loading branch information
Yang-33 authored Nov 7, 2024
1 parent e46ebcf commit cfc2d50
Showing 1 changed file with 8 additions and 1 deletion.
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 Down Expand Up @@ -35,7 +36,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

0 comments on commit cfc2d50

Please sign in to comment.