Skip to content

Commit c33c267

Browse files
authored
Do not create another auto PR when a job runs for PR or merge queue (#1239)
`.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 2908a11 commit c33c267

File tree

2 files changed

+65
-50
lines changed

2 files changed

+65
-50
lines changed

.github/workflows/generate-code.yml

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ name: Generate OpenAPI based code
22

33
on:
44
push:
5+
branches:
6+
- 'master'
57
pull_request:
68
merge_group:
79
workflow_dispatch:
@@ -46,15 +48,24 @@ jobs:
4648
4749
echo "DIFF_IS_EMPTY=$([[ -z "$diff_excluding_submodule" ]] && echo 'true' || echo 'false')" >> $GITHUB_ENV
4850
echo "CURRENT_DATETIME=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
49-
## Run if diff exists and pull request, and make CI status failure (but allow renovate bot)
50-
- if: ${{ github.event_name == 'pull_request' && env.DIFF_IS_EMPTY != 'true' && github.actor != 'renovate[bot]' }}
51+
## Run if diff exists and pull request or merge queue, and make CI status failure (but allow renovate bot)
52+
- if: >-
53+
${{
54+
(github.event_name == 'pull_request' || github.event_name == 'merge_group')
55+
&& env.DIFF_IS_EMPTY != 'true'
56+
&& github.actor != 'renovate[bot]'
57+
}}
5158
run: |
5259
echo "There are changes in the generated codes. Please run 'generate-code.py' and commit the changes." >&2
5360
echo "The files with differences are as follows." >&2
5461
echo "$(git --no-pager diff --name-only HEAD)" >&2
5562
exit 1
56-
## Run if diff exists and event is not pull request, and make PR
57-
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
63+
## Run if diff exists and event is push or workflow_dispatch, make PR
64+
- if: >-
65+
${{
66+
(github.event_name == 'push' || github.event_name == 'workflow_dispatch')
67+
&& env.DIFF_IS_EMPTY != 'true'
68+
}}
5869
run: |
5970
# Determine Change Type via Submodule Script. This scripts read current uncommited changes.
6071
CHANGE_TYPE=$(npx zx ./line-openapi/tools/determine-change-type.mjs)

.github/workflows/test.yml

+50-46
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,61 @@ jobs:
1414
strategy:
1515
matrix:
1616
# https://nodejs.org/en/about/releases/
17-
node: [ '18', '20', '20.12.2', '22' ]
17+
node:
18+
- '18'
19+
- '20'
20+
- '20.12.2'
21+
- '22'
1822
fail-fast: false
1923

2024
name: Node.js ${{ matrix.node }}
2125

2226
steps:
23-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24-
with:
25-
submodules: true
26-
- name: actions/setup-java@v3
27-
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
28-
with:
29-
distribution: 'temurin'
30-
java-version: 17
31-
architecture: x64
32-
- name: Setup Node.js
33-
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
34-
with:
35-
node-version: ${{ matrix.node }}
36-
cache: 'npm'
37-
- name: Install Dependency
38-
run: npm ci
39-
- name: Test generator
40-
run: cd generator; mvn package; cd ..
41-
- name: Generate code
42-
run: |
43-
python3 generate-code.py
44-
- name: Test Project
45-
run: export NODE_OPTIONS=--max-old-space-size=6144; npm test
46-
- name: Test building apidocs
47-
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run apidocs
48-
- name: Test building docs
49-
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run docs:build
50-
- name: Test building examples (CJS)
51-
run: |
52-
cd examples/echo-bot-ts-cjs
53-
npm run build-sdk
54-
npm install
55-
npm run build
56-
cd -
57-
- name: Test building examples (ESM)
58-
run: |
59-
cd examples/echo-bot-ts-esm
60-
npm run build-sdk
61-
npm install
62-
npm run build
63-
cd -
64-
- name: publint
65-
run: npx publint
66-
- name: validate package
67-
run: npx @arethetypeswrong/cli $(npm pack)
27+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
with:
29+
submodules: true
30+
- name: Set up Java
31+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
32+
with:
33+
distribution: 'temurin'
34+
java-version: 17
35+
architecture: x64
36+
- name: Setup Node.js
37+
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
38+
with:
39+
node-version: ${{ matrix.node }}
40+
cache: 'npm'
41+
- name: Install Dependency
42+
run: npm ci
43+
- name: Test generator
44+
run: cd generator; mvn package; cd ..
45+
- name: Generate code
46+
run: |
47+
python3 generate-code.py
48+
- name: Test Project
49+
run: export NODE_OPTIONS=--max-old-space-size=6144; npm test
50+
- name: Test building apidocs
51+
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run apidocs
52+
- name: Test building docs
53+
run: export NODE_OPTIONS=--openssl-legacy-provider; npm run docs:build
54+
- name: Test building examples (CJS)
55+
run: |
56+
cd examples/echo-bot-ts-cjs
57+
npm run build-sdk
58+
npm install
59+
npm run build
60+
cd -
61+
- name: Test building examples (ESM)
62+
run: |
63+
cd examples/echo-bot-ts-esm
64+
npm run build-sdk
65+
npm install
66+
npm run build
67+
cd -
68+
- name: publint
69+
run: npx publint
70+
- name: validate package
71+
run: npx @arethetypeswrong/cli $(npm pack)
6872

6973
pinact:
7074
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)