Build and Deploy Frontend #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy Frontend | |
on: | |
workflow_dispatch: | |
inputs: | |
deploy-env: | |
description: 'The environment to deploy to' | |
required: true | |
type: choice | |
options: | |
- dev | |
- demo | |
storage-account-name: | |
description: 'After the demo env gets created, copy its blob storage name here' | |
required: false | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/build-frontend | |
name: Build frontend | |
with: | |
api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/ | |
frontend-tarball: ./frontend.tgz | |
frontend-path: ./frontend | |
frontend-build-path: ./frontend/dist/ | |
node-version: 20 | |
deploy-with-blob-name-optional: | |
name: Deploy | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.deploy-env }} | |
needs: [build-frontend] | |
steps: | |
- name: Download Artifacts To Job | |
uses: actions/download-artifact@v4 | |
with: | |
name: frontend-tarball | |
- name: Unpack client | |
shell: bash | |
run: | | |
mkdir frontend-deploy; | |
tar -C frontend-deploy -zxvf frontend.tgz | |
- 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 }} | |
object-id: ${{ secrets.AZURE_OBJECT_ID }} | |
- name: Upload to Azure blob storage | |
shell: bash | |
run: | | |
if [ -z "${{ inputs.storage-account-name }}" ]; then | |
az storage blob upload-batch --account-name reportvisionfrontend${{ inputs.deploy-env }} -d '$web' -s frontend-deploy/ --overwrite | |
else | |
az storage blob upload-batch --account-name ${{ inputs.storage-account-name }} -d '$web' -s frontend-deploy/ --overwrite | |
fi | |
- name: Azure logout | |
shell: bash | |
run: | | |
az logout |