Skip to content

Commit

Permalink
GHA frontend build and deploy to Azure blob (#253)
Browse files Browse the repository at this point in the history
* wip

* try react app build workflow

* fix action versions

* change working dir

* change upload path

* rm *

* check dir

* check dist folder

* rm /

* use full path

* add deploy to the same workflow

* was pointing to wrong file name

* add permissions

* try using environment instead of branch

* use creds option

* use IDENTITY as auth-type

* use IDENTITY as auth-type

* rm auth-type

* azure creds

* use storage account name

* change to non fed

* use IDENTITY

* back to app reg

* add correct storage account

* try with fed cred with new sp

* try better download action

* try better download action

* shorten path

* ls

* rm ./

* full path

* test one more time

* main

* delete deploy file

* use workflow dispatch instead of main

* change name of workflow

---------

Co-authored-by: Administrator <[email protected]>
  • Loading branch information
derekadombek and Administrator authored Sep 27, 2024
1 parent ff33af8 commit 552e4f6
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build-deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and Deploy Frontend

on:
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: OCR/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: 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: ./OCR/frontend/client.tgz

deploy:
name: Deploy
runs-on: ubuntu-latest
environment: build-frontend-dev
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: |
az storage blob upload-batch --account-name reportvisionfrontenddev -d '$web' -s client-build/
- name: Azure logout
shell: bash
run: |
az logout

0 comments on commit 552e4f6

Please sign in to comment.