Skip to content

Commit f46b7b8

Browse files
committed
NO-ISSUE PR must fail when generated code is not committed
1 parent e46ebcf commit f46b7b8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

.github/workflows/generated-code.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: Generate code and open pull request
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
branches:
78
- master
@@ -35,7 +36,13 @@ jobs:
3536
diff=$(git --no-pager diff --name-only HEAD)
3637
echo "DIFF_IS_EMPTY=$([[ -z "$diff" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
3738
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
38-
- if: ${{ env.DIFF_IS_EMPTY != 'true' }}
39+
## Run if diff exists and pull request, and make CI status failure
40+
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
41+
run: |
42+
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2
43+
exit 1
44+
## Run if diff exists and event is not pull request, and make PR
45+
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
3946
run: |
4047
git config user.name github-actions
4148
git config user.email [email protected]

0 commit comments

Comments
 (0)