Skip to content

Commit ba4222a

Browse files
committed
chore: extract to reusable workflow
1 parent f0dffb9 commit ba4222a

File tree

2 files changed

+37
-15
lines changed

2 files changed

+37
-15
lines changed

.github/workflows/npm-ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: NPM Install
2+
run-name: "Runner (${{ inputs.runner }}) / Node (${{ inputs.node-version }})"
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
runner:
8+
required: true
9+
type: string
10+
node-version:
11+
required: true
12+
type: string
13+
14+
jobs:
15+
npm-install:
16+
name: "NPM Install (${{ inputs.runner }}) / Node (${{ inputs.node-version }})"
17+
runs-on: ${{ inputs.runner }}
18+
steps:
19+
- name: Install NodeJS ${{ inputs.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ inputs.node-version }}
23+
- name: Get npm cache directory
24+
id: npm-cache-dir
25+
shell: bash
26+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
27+
- uses: actions/cache@v4
28+
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
29+
with:
30+
path: ${{ steps.npm-cache-dir.outputs.dir }}
31+
key: ${{ inputs.runner }}-node-{{ inputs.node-version }}-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ inputs.runner }}-node-{{ inputs.node-version }}-
34+
- name: Install dependencies
35+
run: npm ci --omit=optional

.github/workflows/test.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,10 @@ jobs:
2929
steps:
3030
- name: Code checkout
3131
uses: actions/checkout@v4
32-
- name: Install NodeJS ${{ matrix.node-version }}
33-
uses: actions/setup-node@v4
32+
- uses: ./.github/workflows/npm-ci.yml
3433
with:
34+
runner: ${{ matrix.runner }}
3535
node-version: ${{ matrix.node-version }}
36-
- name: Install dependencies
37-
run: npm ci --omit=optional
38-
- name: Get npm cache directory
39-
id: npm-cache-dir
40-
shell: bash
41-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
42-
- uses: actions/cache@v4
43-
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
44-
with:
45-
path: ${{ steps.npm-cache-dir.outputs.dir }}
46-
key: ${{ runner.os }}-node-{{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
47-
restore-keys: |
48-
${{ runner.os }}-node-{{ matrix.node-version }}-
4936
- name: Build workspaces
5037
run: npm run build -ws
5138
- name: Remove dev dependencies

0 commit comments

Comments
 (0)