Skip to content

Commit 711e76e

Browse files
authored
Do not create another auto PR when a job runs for PR or merge queue (#798)
`.github/workflows/generate-code.yml` creates another PR when the submitted PR or merge queue job detects diff ... 😄 This change fixes it. original: line/line-bot-sdk-java#1598
1 parent 1fc4f01 commit 711e76e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

.github/workflows/generate-code.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Generate code and open pull request
22

33
on:
44
push:
5+
branches:
6+
- 'master'
57
pull_request:
68
merge_group:
79
workflow_dispatch:
@@ -31,15 +33,24 @@ jobs:
3133
3234
echo "DIFF_IS_EMPTY=$([[ -z "$diff_excluding_submodule" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
3335
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
34-
## Run if diff exists and pull request, and make CI status failure (but allow renovate bot)
35-
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' && github.actor != 'renovate[bot]' }}
36+
## Run if diff exists and pull request or merge queue, and make CI status failure (but allow renovate bot)
37+
- if: >-
38+
${{
39+
(github.event_name == 'pull_request' || github.event_name == 'merge_group')
40+
&& env.DIFF_IS_EMPTY != 'true'
41+
&& github.actor != 'renovate[bot]'
42+
}}
3643
run: |
3744
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2
3845
echo "The files with differences are as follows." >&2
3946
echo "$(git --no-pager diff --name-only HEAD)" >&2
4047
exit 1
41-
## Run if diff exists and event is not pull request, and make PR
42-
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
48+
## Run if diff exists and event is push or workflow_dispatch, make PR
49+
- if: >-
50+
${{
51+
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
52+
&& env.DIFF_IS_EMPTY != 'true'
53+
}}
4354
run: |
4455
# Determine Change Type via Submodule Script. This scripts read current uncommited changes.
4556
CHANGE_TYPE=$(npx zx ./line-openapi/tools/determine-change-type.mjs)

0 commit comments

Comments
 (0)