Skip to content

Commit b477e20

Browse files
chore: sync workflows
1 parent 129e7c6 commit b477e20

File tree

5 files changed

+80
-33
lines changed

5 files changed

+80
-33
lines changed

.github/workflows/add-version-tag.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ on:
77
name: Add version tag
88

99
jobs:
10-
release:
10+
tag:
11+
name: Add version tag
1112
runs-on: ubuntu-latest
12-
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
13+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
1314
steps:
1415
- name: Get version
1516
run: echo "::set-env name=TAG_NAME::${HEAD_REF#release/}"

.github/workflows/check-version.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,57 +141,67 @@ jobs:
141141
matrix:
142142
target: ['npm']
143143
steps:
144+
- name: Set running flag
145+
run: echo "::set-env name=RUNNING::1"
146+
- name: Set running flag
147+
run: |
148+
if [ -z "$NPM_AUTH_TOKEN" ]; then
149+
echo "::set-env name=RUNNING::"
150+
fi
151+
env:
152+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
153+
144154
- uses: actions/checkout@v2
155+
if: env.RUNNING
145156
- name: Setup Node.js
146157
uses: actions/setup-node@v1
147158
with:
148159
node-version: 12
149160
registry-url: https://registry.npmjs.org/
150-
if: matrix.target == 'npm'
161+
if: env.RUNNING && matrix.target == 'npm'
151162
- name: Setup Node.js
152163
uses: actions/setup-node@v1
153164
with:
154165
node-version: 12
155166
registry-url: https://npm.pkg.github.com
156-
if: matrix.target == 'gpr'
167+
if: env.RUNNING && matrix.target == 'gpr'
157168
- name: Get Yarn Cache Directory
158169
id: yarn-cache
159170
run: echo "::set-output name=dir::$(yarn cache dir)"
171+
if: env.RUNNING
160172
- name: Cache node dependencies
161173
uses: actions/cache@v1
162174
with:
163175
path: ${{ steps.yarn-cache.outputs.dir }}
164176
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
165177
restore-keys: |
166178
${{ runner.os }}-yarn-
167-
179+
if: env.RUNNING
168180
- name: Check package version
169181
uses: technote-space/package-version-check-action@v1
170182
with:
171183
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
172184
COMMIT_DISABLED: 1
185+
if: env.RUNNING
173186
- name: Install Package dependencies
174187
run: yarn install
188+
if: env.RUNNING
175189
- name: Build
176190
run: yarn build
191+
if: env.RUNNING
177192
- name: Publish
178193
run: |
179-
if [ -n "$NPM_AUTH_TOKEN" ]; then
180-
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
181-
npm publish
182-
fi
194+
npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
195+
npm publish
183196
env:
184197
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
185-
if: matrix.target == 'npm'
198+
if: env.RUNNING && matrix.target == 'npm'
186199
- name: Publish
187200
run: |
188-
if [ -n "$NPM_AUTH_TOKEN" ]; then
189-
npm publish
190-
fi
201+
npm publish
191202
env:
192203
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
193-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
194-
if: matrix.target == 'gpr'
204+
if: env.RUNNING && matrix.target == 'gpr'
195205
- uses: 8398a7/action-slack@v2
196206
with:
197207
status: failure

.github/workflows/pr-opened.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,24 @@ jobs:
3333
uses: technote-space/pr-labeler-action@v3
3434
with:
3535
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
checkVersion:
38+
name: Check package version
39+
runs-on: ubuntu-latest
40+
if: startsWith(github.event.pull_request.head.ref, 'release/')
41+
steps:
42+
- name: Set running flag
43+
run: echo "::set-env name=RUNNING::1"
44+
- uses: actions/checkout@v2
45+
- name: Set running flag
46+
run: |
47+
if [[ ! -f package.json ]] || [[ $(< package.json jq -r '.version == null') == 'true' ]]; then
48+
echo "::set-env name=RUNNING::"
49+
fi
50+
51+
- name: Check package version
52+
uses: technote-space/package-version-check-action@v1
53+
with:
54+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
55+
BRANCH_PREFIX: release/
56+
if: env.RUNNING

.github/workflows/pr-updated.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
on: pull_request
1+
on:
2+
pull_request:
3+
types: [opened, synchronize]
24

35
name: Pull Request updated
46

57
jobs:
68
triage:
79
name: Pull Request Labeler
810
runs-on: ubuntu-latest
9-
if: "! startsWith(github.event.pull_request.head.ref, 'release/v')"
11+
if: "! startsWith(github.event.pull_request.head.ref, 'release/')"
1012
steps:
1113
- name: Pull Request Labeler
1214
uses: actions/labeler@v2
@@ -16,6 +18,7 @@ jobs:
1618
assignToProject:
1719
name: Assign PullRequest to Project
1820
runs-on: ubuntu-latest
21+
if: github.event.action == 'synchronize'
1922
steps:
2023
- uses: actions/checkout@v2
2124
- uses: technote-space/get-git-comment-action@v1
@@ -31,6 +34,7 @@ jobs:
3134
assignAuthor:
3235
name: Assign author to PR
3336
runs-on: ubuntu-latest
37+
if: github.event.action == 'synchronize'
3438
steps:
3539
- uses: actions/checkout@v2
3640
- uses: technote-space/get-git-comment-action@v1
@@ -44,6 +48,7 @@ jobs:
4448
addLabelsByBranch:
4549
name: PR Labeler
4650
runs-on: ubuntu-latest
51+
if: github.event.action == 'synchronize'
4752
steps:
4853
- uses: actions/checkout@v2
4954
- uses: technote-space/get-git-comment-action@v1
@@ -53,3 +58,29 @@ jobs:
5358
with:
5459
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5560
IGNORE_CONTEXT_CHECK: true
61+
62+
checkVersion:
63+
name: Check package version
64+
runs-on: ubuntu-latest
65+
if: github.event.action == 'synchronize' && startsWith(github.event.pull_request.head.ref, 'release/')
66+
steps:
67+
- name: Set running flag
68+
run: echo "::set-env name=RUNNING::"
69+
- uses: actions/checkout@v2
70+
- uses: technote-space/get-git-comment-action@v1
71+
- name: Set running flag
72+
run: echo "::set-env name=RUNNING::1"
73+
if: contains(env.COMMIT_MESSAGE, 'trigger workflow')
74+
- name: Set running flag
75+
run: |
76+
if [[ ! -f package.json ]] || [[ $(< package.json jq -r '.version == null') == 'true' ]]; then
77+
echo "::set-env name=RUNNING::"
78+
fi
79+
80+
- name: Check package version
81+
uses: technote-space/package-version-check-action@v1
82+
with:
83+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
84+
BRANCH_PREFIX: release/
85+
IGNORE_CONTEXT_CHECK: true
86+
if: env.RUNNING

0 commit comments

Comments
 (0)