-
Notifications
You must be signed in to change notification settings - Fork 22
125 lines (120 loc) · 4.04 KB
/
build_and_deploy.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: build_and_deploy
on:
workflow_call:
inputs:
ref:
required: true
type: string
noop:
default: "false"
required: false
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: build
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-node@v4
with:
node-version-file: ".tool-versions"
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
working-directory: frontend
- uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ hashFiles('**/frontend/package-lock.json') }}
${{ runner.os }}-node-
- name: Install Dependencies
working-directory: frontend
run: npm ci --include=dev
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
with:
path: frontend
- name: Generate elm-constants
working-directory: frontend
run: npm run generate:elm-constants
env:
API_ROOT: ${{ secrets.API_ROOT }}
WEB_ROOT: ${{ secrets.WEB_ROOT }}
APP_VERSION: ${{ steps.package-version.outputs.current-version }}
REPO_BUTTON_URL: ${{ secrets.REPO_BUTTON_URL }}
- name: build
working-directory: frontend
env:
API_ROOT: ${{ secrets.API_ROOT }}
WEB_ROOT: ${{ secrets.WEB_ROOT }}
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }}
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
FIREBASE_AUTH_EMULATOR_HOST: ""
SENTRY_ENABLE: ${{ secrets.SENTRY_ENABLE }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_RELEASE: ${{ steps.package-version.outputs.current-version}}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
MONITOR_ENABLE: ${{ secrets.MONITOR_ENABLE }}
run: npm run prod
- name: Archive Production Artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: frontend/dist
retention-days: 3
deploy-frontend:
name: deploy-frontend
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: dist
path: frontend/dist
- uses: FirebaseExtended/action-hosting-deploy@v0
if: ${{ inputs.noop != 'true' }}
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_TEXTUSM }}"
projectId: textusm
target: textusm
channelId: live
deploy-backend:
name: deploy-backend
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
if: ${{ inputs.noop != 'true' }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-node@v4
if: ${{ inputs.noop != 'true' }}
with:
node-version-file: ".tool-versions"
- name: Deploy backend to render.com
if: ${{ inputs.noop != 'true' }}
run: curl --silent --show-error --fail $RENDER_DEPLOY_HOOK_URL > /dev/null
env:
RENDER_DEPLOY_HOOK_URL: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}