-
Notifications
You must be signed in to change notification settings - Fork 26
111 lines (96 loc) · 3.69 KB
/
test-app-build.yml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
##################################################################################
# About
##################################################################################
# Reuseable workflow to be called from content repos.
# Allows for parent repo.
# Must specify all below secrets and variables - see documentation for details
#
# Version : 1.0
#
##################################################################################
# Configuration
##################################################################################
env:
DEPLOYMENT_NAME: ${{vars.DEPLOYMENT_NAME}}
APP_CODE_BRANCH: ${{vars.APP_CODE_BRANCH}}
PARENT_DEPLOYMENT_REPO: ${{vars.PARENT_DEPLOYMENT_REPO}}
PARENT_DEPLOYMENT_NAME: ${{vars.PARENT_DEPLOYMENT_NAME}}
PARENT_DEPLOYMENT_BRANCH: ${{vars.PARENT_DEPLOYMENT_BRANCH}}
DEPLOYMENT_PRIVATE_KEY: ${{secrets.DEPLOYMENT_PRIVATE_KEY}}
FIREBASE_CONFIG: ${{secrets.FIREBASE_CONFIG}}
##################################################################################
# Main Code
##################################################################################
name: Build App
# Only keep one active build per ref (e.g. pr branch, push branch, triggering workflow ref)
concurrency:
group: app-build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_call:
inputs:
artifact-name:
description: Name of the artifact to upload
type: string
default: www
build-flags:
description: Additional flags to pass to build command (e.g. base-href)
type: string
default: ""
branch:
description: Name of branch to build (defaults to event trigger sha)
type: string
default: ""
outputs:
GIT_SHA:
description: "Git SHA of build head"
value: ${{ jobs.configure_build.outputs.GIT_SHA }}
jobs:
build:
outputs:
GIT_SHA: ${{ steps.populate.outputs.GIT_SHA }}
runs-on: ubuntu-latest
steps:
- name: Check out app code
uses: actions/checkout@v3
with:
repository: "IDEMSInternational/parenting-app-ui.git"
ref: ${{env.APP_CODE_BRANCH}}
- name: Checkout parent repo if needed
if: env.PARENT_DEPLOYMENT_REPO != ''
uses: actions/checkout@v3
with:
path: ".idems_app/deployments/${{env.PARENT_DEPLOYMENT_NAME}}"
repository: ${{env.PARENT_DEPLOYMENT_REPO}}
ref: ${{env.PARENT_DEPLOYMENT_BRANCH}}
- name: Checkout deployment
uses: actions/checkout@v3
with:
ref: ${{inputs.branch}}
path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}"
- name: Populate Encryption key
if: env.DEPLOYMENT_PRIVATE_KEY != ''
run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Cache node modules
uses: actions/cache@v3
with:
path: ./.yarn/cache
# If cachebusting required (e.g. breaking yarn changes on update) change `v1` to another number
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-yarn-v1-
- name: Install node modules
run: yarn install
- name: Set deployment
run: yarn workflow deployment set $DEPLOYMENT_NAME
- name: Build
run: yarn build ${{inputs.build-flags}}
- name: Upload artifact
uses: actions/[email protected]
with:
path: "www/"
name: ${{inputs.artifact-name}}