Skip to content

Commit 29aa95b

Browse files
committed
Add setup action
1 parent c612b8a commit 29aa95b

File tree

5 files changed

+47
-48
lines changed

5 files changed

+47
-48
lines changed

.github/actions/setup/action.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
name: Setup
3+
description: Setup Node.js and install dependencies.
4+
5+
inputs:
6+
node_version:
7+
description: The Node.js version
8+
required: false
9+
default: '16'
10+
registry_url:
11+
description: The Node.js package registry URL.
12+
required: false
13+
default: https://registry.npmjs.org
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Setup Node.js
19+
uses: actions/setup-node@v2
20+
with:
21+
cache: npm
22+
node-version: ${{ inputs.node_version }}
23+
registry-url: ${{ inputs.registry_url }}
24+
- name: Install dependencies
25+
shell: bash
26+
run: npm ci

.github/workflows/format.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ jobs:
2929
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
3030
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
3131
passphrase: ${{ secrets.GPG_PASSPHRASE }}
32-
- name: Setup Node.js
33-
uses: actions/setup-node@v2
34-
with:
35-
node-version: '16'
36-
cache: npm
37-
registry-url: https://npm.pkg.github.com
38-
scope: '@${{ github.repository_owner }}'
39-
- name: Install dependencies
40-
run: npm ci
32+
- name: Setup
33+
uses: ./.github/actions/setup
4134
- name: Format
4235
run: npm run format
4336
- name: Commit

.github/workflows/main.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v2
21-
- name: Setup Node.js
22-
uses: actions/setup-node@v2
21+
- name: Setup
22+
uses: ./.github/actions/setup
2323
with:
24-
node-version: ${{ matrix.node }}
25-
cache: npm
26-
- name: Install dependencies
27-
run: npm ci
24+
node_version: ${{ matrix.node }}
2825
- name: Test
2926
run: npm test
3027
lint:
@@ -38,13 +35,10 @@ jobs:
3835
steps:
3936
- name: Checkout
4037
uses: actions/checkout@v2
41-
- name: Setup Node.js
42-
uses: actions/setup-node@v2
38+
- name: Setup
39+
uses: ./.github/actions/setup
4340
with:
44-
node-version: ${{ matrix.node }}
45-
cache: npm
46-
- name: Install dependencies
47-
run: npm ci
41+
node_version: ${{ matrix.node }}
4842
- name: Lint
4943
run: npm run lint
5044
build:
@@ -58,12 +52,9 @@ jobs:
5852
steps:
5953
- name: Checkout
6054
uses: actions/checkout@v2
61-
- name: Setup Node.js
62-
uses: actions/setup-node@v2
55+
- name: Setup
56+
uses: ./.github/actions/setup
6357
with:
64-
node-version: ${{ matrix.node }}
65-
cache: npm
66-
- name: Install dependencies
67-
run: npm ci
58+
node_version: ${{ matrix.node }}
6859
- name: Build
6960
run: npm run build

.github/workflows/publish.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
15-
- name: Setup Node.js
16-
uses: actions/setup-node@v2
15+
- name: Setup
16+
uses: ./.github/actions/setup
1717
with:
18-
node-version: '12'
19-
cache: npm
20-
registry-url: https://registry.npmjs.org
18+
node_version: '12'
19+
registry_url: https://registry.npmjs.org
2120
- name: Check version
2221
id: version
2322
run: |
@@ -26,8 +25,6 @@ jobs:
2625
echo "::set-output name=published::$(npm view $(jq -r '.name' package.json)@$(jq -r '.version' package.json) version)"
2726
env:
2827
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29-
- name: Install dependencies
30-
run: npm ci
3128
- name: Build
3229
run: npn run build
3330
- name: Publish ${{ steps.version.outputs.name }}@${{ steps.version.outputs.current }}
@@ -40,12 +37,11 @@ jobs:
4037
steps:
4138
- name: Checkout
4239
uses: actions/checkout@v2
43-
- name: Setup Node.js
44-
uses: actions/setup-node@v2
40+
- name: Setup
41+
uses: ./.github/actions/setup
4542
with:
46-
node-version: '12'
47-
cache: npm
48-
registry-url: https://npm.pkg.github.com
43+
node_version: '12'
44+
registry_url: https://npm.pkg.github.com
4945
- name: Check version
5046
id: version
5147
run: |
@@ -54,8 +50,6 @@ jobs:
5450
echo "::set-output name=published::$(npm view $(jq -r '.name' package.json)@$(jq -r '.version' package.json) version)"
5551
env:
5652
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
- name: Install dependencies
58-
run: npm ci
5953
- name: Build
6054
run: npm run build
6155
- name: Publish ${{ steps.version.outputs.name }}@${{ steps.version.outputs.current }}

.github/workflows/version.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ jobs:
4040
git_committer_email: ${{ secrets.GIT_USER_EMAIL }}
4141
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
4242
passphrase: ${{ secrets.GPG_PASSPHRASE }}
43-
- name: Setup Node.js
44-
uses: actions/setup-node@v2
45-
with:
46-
node-version: '16'
47-
cache: npm
48-
- name: Install dependencies
49-
run: npm ci
43+
- name: Setup
44+
uses: ./.github/actions/setup
5045
- name: Cut ${{ github.event.inputs.version }}${{ github.event.client_payload.version }} version
5146
run: npm version ${{ github.event.inputs.version }}${{ github.event.client_payload.version }}

0 commit comments

Comments
 (0)