-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (69 loc) · 2.36 KB
/
node-build.yml
File metadata and controls
78 lines (69 loc) · 2.36 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
on:
workflow_call:
inputs:
node-version:
required: false
type: string
default: 24.x
working-directory:
required: false
type: string
default: '.'
build-path:
required: false
type: string
default: build
artifact-name:
required: false
type: string
default: node-app
pre-run-script:
required: false
type: string
secrets:
npm-auth-token:
description: NPM auth token (optional, GITHUB_TOKEN is used by default)
required: false
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ${{ inputs.working-directory }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
# setup node + private repo access
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version: ${{ inputs.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@makerxstudio'
cache: 'npm'
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json
- name: Pre-run
if: ${{ inputs.pre-run-script }}
run: ${{ inputs.pre-run-script }}
# run npm ci preventing script access to npm auth token
- run: npm ci --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token || secrets.GITHUB_TOKEN }}
# allow scripts to run without npm auth token
- run: npm rebuild && npm run prepare --if-present
- name: Prepare
run: npm run prepare --if-present
- name: Build
run: npm run build
# CDK infrastructure build calls npm ci on /infrastructure/build, which may fail without NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.npm-auth-token || secrets.GITHUB_TOKEN }}
- name: Upload artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.working-directory }}/${{ inputs.build-path }}
if-no-files-found: error