diff --git a/.github/workflows/generated-code.yml b/.github/workflows/generated-code.yml index c1b08827..3e11d66a 100644 --- a/.github/workflows/generated-code.yml +++ b/.github/workflows/generated-code.yml @@ -2,6 +2,7 @@ name: Generate code and open pull request on: workflow_dispatch: + pull_request: push: branches: - master @@ -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