Skip to content

whoops didnt change var #15

whoops didnt change var

whoops didnt change var #15

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: xjvw1dq9tg7srfo2ylonkgxb
deploy-env: demo
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: demo
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
run: |
if [ -z "${{ env.demo-blob-name }}" ]; then
az storage blob upload-batch --account-name reportvisionfrontend${{ env.deploy-env }} -d '$web' -s client-build/ --overwrite
else
az storage blob upload-batch --account-name ${{ env.demo-blob-name }} -d '$web' -s client-build/ --overwrite
fi
- name: Azure logout
shell: bash
run: |
az logout