-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (89 loc) · 2.63 KB
/
node-pnpm.yml
File metadata and controls
97 lines (89 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Reusable Node (pnpm) CI
on:
workflow_call:
inputs:
node-version:
description: Node.js version
required: false
type: string
pnpm-version:
description: pnpm version
required: false
type: string
working-directory:
description: Directory with package.json
required: false
type: string
default: "."
frozen-lockfile:
description: Use --frozen-lockfile
required: false
type: boolean
default: true
build-script:
description: Name of build script to run
required: false
type: string
default: "build"
test-script:
description: Name of test script to run
required: false
type: string
default: "test"
test-args:
description: Additional args to pass to test script
required: false
type: string
default: ""
registry-url:
description: Optional npm registry URL
required: false
type: string
default: ""
secrets:
NPM_TOKEN:
required: false
env:
NODE_VERSION: ${{ inputs.node-version || '20' }}
PNPM_VERSION: ${{ inputs.pnpm-version || '9' }}
jobs:
node:
name: Node (pnpm) Build & Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Configure npm auth (if token provided)
if: ${{ inputs.registry-url != '' && secrets.NPM_TOKEN != '' }}
shell: bash
run: |
set -euo pipefail
REG="${{ inputs.registry-url }}"
HOST=$(echo "$REG" | sed -E 's#^https?://##')
case "$HOST" in
*/) ;;
*) HOST="$HOST/" ;;
esac
npm config set //${HOST}:_authToken="${{ secrets.NPM_TOKEN }}"
- name: Setup Node & pnpm
uses: ./.github/actions/pnpm-setup
with:
node-version: ${{ env.NODE_VERSION }}
pnpm-version: ${{ env.PNPM_VERSION }}
registry-url: ${{ inputs.registry-url }}
- name: Install
uses: ./.github/actions/pnpm-install
with:
working-directory: ${{ inputs.working-directory }}
frozen-lockfile: ${{ inputs.frozen-lockfile }}
- name: Build
uses: ./.github/actions/pnpm-build
with:
working-directory: ${{ inputs.working-directory }}
script: ${{ inputs.build-script }}
- name: Test
uses: ./.github/actions/node-test
with:
working-directory: ${{ inputs.working-directory }}
script: ${{ inputs.test-script }}
args: ${{ inputs.test-args }}