-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
87 lines (75 loc) · 2.38 KB
/
action.yaml
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
name: Frontend Build-Action
description: 'build and push to s3'
inputs:
PAT:
description: 'PAT from repo'
required: true
NODE_VERSION:
description: 'node version'
required: false
default: 'latest'
WORKING_DIRECTORY:
description: 'working directory'
required: true
default: ''
BUCKET_NAME:
description: 'bucket name'
required: true
OUTPUT_PATH:
description: 'output path'
required: false
default: 'dist'
outputs:
bucket_name:
description: 'bucket_name'
value: ${{ steps.bucket_name.outputs.bucket_name }}
runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js ${{ inputs.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
cache: 'npm'
- name: Authenticate with private NPM package
run: |
echo "@entrecode:registry=https://npm.pkg.github.com/" > ./.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ inputs.PAT }}" > ./.npmrc
working-directory: ${{ github.workspace }}/${{ inputs.WORKING_DIRECTORY }}
shell: bash
- name: Install Dependencies
run: npm ci --prefer-offline --no-audit --quiet
working-directory: ${{ github.workspace }}/${{ inputs.WORKING_DIRECTORY }}
shell: bash
- name: Build stage
if: startsWith(github.ref, 'refs/tags/') != true
id: build_stage
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: |
npm run stage
echo "bucket_name=${{ inputs.BUCKET_NAME }}-stage" >> $GITHUB_OUTPUT
working-directory: ${{ github.workspace }}/${{ inputs.WORKING_DIRECTORY }}
shell: bash
- name: Build prod
if: startsWith(github.ref, 'refs/tags/')
id: build_prod
env:
NODE_OPTIONS: '--max_old_space_size=4096'
run: |
npm run prod
echo "bucket_name=${{ inputs.BUCKET_NAME }}-prod" >> $GITHUB_OUTPUT
working-directory: ${{ github.workspace }}/${{ inputs.WORKING_DIRECTORY }}
shell: bash
- name: Create Bucket Name Output
id: bucket_name
run: echo "bucket_name=${{ steps.build_stage.outputs.bucket_name || steps.build_prod.outputs.bucket_name }}" >> $GITHUB_OUTPUT
shell: bash
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build_result
path: ${{ github.workspace }}/${{ inputs.WORKING_DIRECTORY }}/${{ inputs.OUTPUT_PATH }}/
retention-days: 2