-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
91 lines (80 loc) · 2.66 KB
/
action.yml
File metadata and controls
91 lines (80 loc) · 2.66 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
name: Build Node zip
description: Build Node app and upload zip artifact
inputs:
node-version:
description: Node version
required: false
default: 18.x
working-directory:
description: Working directory
required: false
default: '.'
build-path:
description: Build output path
required: false
default: build
artifact-name:
description: Artifact name
required: false
default: node-app
static-site:
required: false
default: false
static-site-env-prefix:
required: false
default: VITE
npm-auth-token:
description: NPM auth token (optional)
required: false
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
# setup node + private repo access
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@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
# prepare static sites for config transformation upon later deployment
- if: ${{ inputs.static-site }}
run: sed -n 's/\(${{ inputs.static-site-env-prefix }}_[A-Z0-9_]\+\)=\(.*\)/\1={{\1}}/p' .env.sample > .env && cat .env
working-directory: ${{ inputs.working-directory }}
shell: bash
# run npm ci preventing script access to npm auth token
- run: npm ci --ignore-scripts
working-directory: ${{ inputs.working-directory }}
shell: bash
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-auth-token }}
# allow scripts to run without npm auth token
- run: npm rebuild && npm run prepare --if-present
working-directory: ${{ inputs.working-directory }}
shell: bash
- name: Prepare
run: npm run prepare --if-present
working-directory: ${{ inputs.working-directory }}
shell: bash
- name: Build
run: npm run build
working-directory: ${{ inputs.working-directory }}
shell: bash
# CDK infrastructure build calls npm ci on /infrastructure/build, which may fail without NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ inputs.npm-auth-token }}
- name: Zip build folder
run: pushd ${{ inputs.build-path }}; zip -q -r ../${{ inputs.artifact-name }}.zip *
working-directory: ${{ inputs.working-directory }}
shell: bash
- name: Upload artifact
uses: actions/upload-artifact@v5
with:
name: ${{ inputs.artifact-name }}
path: ${{ inputs.working-directory }}/${{ inputs.artifact-name }}.zip
if-no-files-found: error