Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit b0a0e46

Browse files
committed
Add common action as composite
1 parent f24dde7 commit b0a0e46

4 files changed

Lines changed: 47 additions & 47 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ insert_final_newline = true
99
tab_width = 4
1010
trim_trailing_whitespace = true
1111

12-
[.github/workflows/*.yml]
12+
[.github/{actions,workflows}/*.yml]
1313
indent_size = 2
1414
tab_width = 2

.github/actions/common.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
2+
name: Common
3+
description: Common action logic.
4+
inputs:
5+
node-version:
6+
description: Node.js version to use.
7+
required: true
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Use Node.js ${{ matrix.node-version }}
12+
uses: actions/setup-node@v2
13+
with:
14+
node-version: ${{ matrix.node-version }}
15+
- name: Get npm cache directory
16+
id: npm-cache-dir
17+
shell: bash
18+
run: |
19+
echo "::set-output name=dir::$(npm config get cache)"
20+
- name: Cache root node_modules
21+
id: cache-npm-root
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
${{ steps.npm-cache-dir.outputs.dir }}
26+
./node_modules
27+
key: ${{ runner.os }}-node-root-${{ hashFiles('./package-lock.json') }}
28+
restore-keys: |
29+
${{ runner.os }}-node-root-
30+
- name: Install dependencies
31+
if: ${{ steps.cache-npm-root.outputs.cache-hit != 'true' }}
32+
shell: bash
33+
run: npm ci
34+
- name: Lerna bootstrap
35+
shell: bash
36+
run: npx lerna bootstrap

.github/workflows/ci.yml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,9 @@ jobs:
1818
NODE_VERSION: 18
1919
steps:
2020
- uses: actions/checkout@v2
21-
- name: Use Node.js ${{ env.NODE_VERSION }}
22-
uses: actions/setup-node@v2
21+
- uses: ./.github/actions/common.yml
2322
with:
2423
node-version: ${{ env.NODE_VERSION }}
25-
- name: Get npm cache directory
26-
id: npm-cache-dir
27-
run: |
28-
echo "::set-output name=dir::$(npm config get cache)"
29-
- name: Cache root node_modules
30-
id: cache-npm-root
31-
uses: actions/cache@v3
32-
with:
33-
path: |
34-
${{ steps.npm-cache-dir.outputs.dir }}
35-
./node_modules
36-
key: ${{ runner.os }}-node-root-${{ hashFiles('./package-lock.json') }}
37-
restore-keys: |
38-
${{ runner.os }}-node-root-
39-
- name: Install dependencies
40-
if: ${{ steps.cache-npm-root.outputs.cache-hit != 'true' }}
41-
run: npm ci
42-
- name: Lerna bootstrap
43-
run: npx lerna bootstrap
4424
- name: Build
4525
run: npx lerna run build
4626

@@ -53,29 +33,9 @@ jobs:
5333
node-version: [18]
5434
steps:
5535
- uses: actions/checkout@v2
56-
- name: Use Node.js ${{ matrix.node-version }}
57-
uses: actions/setup-node@v2
36+
- uses: ./.github/actions/common.yml
5837
with:
5938
node-version: ${{ matrix.node-version }}
60-
- name: Get npm cache directory
61-
id: npm-cache-dir
62-
run: |
63-
echo "::set-output name=dir::$(npm config get cache)"
64-
- name: Cache root node_modules
65-
id: cache-npm-root
66-
uses: actions/cache@v3
67-
with:
68-
path: |
69-
${{ steps.npm-cache-dir.outputs.dir }}
70-
./node_modules
71-
key: ${{ runner.os }}-node-root-${{ hashFiles('./package-lock.json') }}
72-
restore-keys: |
73-
${{ runner.os }}-node-root-
74-
- name: Install dependencies
75-
if: ${{ steps.cache-npm-root.outputs.cache-hit != 'true' }}
76-
run: npm ci
77-
- name: Lerna bootstrap
78-
run: npx lerna bootstrap
7939
- name: Test
8040
run: npx lerna run test
8141
env:

.github/workflows/npm-publish.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ name: Publish
22

33
on:
44
release:
5-
types: [created, edited, published]
5+
types:
6+
- created
7+
8+
env:
9+
NODE_VERSION: 18
610

711
jobs:
812
test:
@@ -11,7 +15,7 @@ jobs:
1115
- uses: actions/checkout@v2
1216
- uses: actions/setup-node@v2
1317
with:
14-
node-version: 14
18+
node-version: ${{ env.NODE_VERSION }}
1519
- run: npm ci
1620
- run: npm test
1721

@@ -22,9 +26,9 @@ jobs:
2226
- uses: actions/checkout@v2
2327
- uses: actions/setup-node@v2
2428
with:
25-
node-version: 14
29+
node-version: ${{ env.NODE_VERSION }}
2630
registry-url: https://registry.npmjs.org/
2731
- run: npm ci
2832
- run: npm publish
2933
env:
30-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
34+
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

0 commit comments

Comments
 (0)