generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
101 lines (95 loc) · 2.77 KB
/
build-deploy-frontend.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
name: Build and Deploy Frontend
on:
push:
branches: update-frontend-deploy-for-demo-env
# workflow_dispatch:
# inputs:
# deploy-env:
# description: 'The environment to deploy to'
# required: true
# type: choice
# options:
# - dev
# - dev2
# - dev3
# - dev4
# - dev5
# - dev6
# - demo
# demo-blob-name:
# description: 'After the demo env gets created, copy its blob storage name here'
# required: false
env:
demo-blob-name:
deploy-env: dev4
permissions:
id-token: write
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install NPM packages
run: npm ci
- name: Build project
run: VITE_API_URL='https://reportvision-ocr-${{ env.deploy-env }}.azurewebsites.net/' npm run build
- name: Run unit tests
run: npm run test
- name: Create client build archive
shell: bash
run: |
echo "::group::Create application archive"
tar -C ./dist/ -czf ./client.tgz .
echo "::endgroup::"
- name: Upload production-ready build files
uses: actions/upload-artifact@v4
with:
name: production-files
path: ./frontend/client.tgz
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: dev4
needs: [build]
steps:
- name: Download Artifacts To Job
uses: actions/download-artifact@v4
with:
name: production-files
- name: Unpack client
shell: bash
run: |
echo "::group::Unpack client"
mkdir client-build;
tar -C client-build -zxvf client.tgz
echo "::endgroup::"
- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Upload to Azure blob storage
shell: bash
if: ${{ env.demo-blob-name == '' }}
run: |
az storage blob upload-batch --account-name reportvisionfrontend${{ env.deploy-env }} -d '$web' -s client-build/ --overwrite
- name: Upload to Azure blob storage
shell: bash
if: ${{ env.demo-blob-name != '' }}
run: |
az storage blob upload-batch --account-name ${{ env.demo-blob-name }} -d '$web' -s client-build/ --overwrite
- name: Azure logout
shell: bash
run: |
az logout