Skip to content

Commit

Permalink
test frontend workflow with changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Administrator committed Nov 4, 2024
1 parent ed944d9 commit d4d5622
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 94 deletions.
86 changes: 31 additions & 55 deletions .github/workflows/build-deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,44 @@
name: Build and Deploy Frontend

on:
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
push:
branches: fix-docker-image-check
# workflow_dispatch:
# inputs:
# deploy-env:
# description: 'The environment to deploy to'
# required: true
# type: choice
# options:
# - dev
# - demo
# demo-blob-name:
# description: 'After the demo env gets created, copy its blob storage name here'
# required: false

permissions:
id-token: write
contents: read

jobs:
build:
name: Build
build-frontend:
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
- uses: actions/checkout@v4
- uses: ./.github/actions/build-frontend
name: Build frontend
with:
node-version: '20'
- name: Install NPM packages
run: npm ci
- name: Build project
run: VITE_API_URL='https://reportvision-ocr-${{ inputs.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
api-endpoint: https://reportvision-ocr-dev.azurewebsites.net/
frontend-tarball: ./frontend.tgz
frontend-path: ./frontend
frontend-build-path: ./frontend/dist/
node-version: 20

deploy:
deploy-with-blob-name-optional:
name: Deploy
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
needs: [build]
environment: dev
needs: [build-frontend]
steps:
- name: Download Artifacts To Job
uses: actions/download-artifact@v4
Expand All @@ -69,10 +47,8 @@ jobs:
- name: Unpack client
shell: bash
run: |
echo "::group::Unpack client"
mkdir client-build;
tar -C client-build -zxvf client.tgz
echo "::endgroup::"
mkdir frontend-deploy;
tar -C frontend-deploy -zxvf frontend.tgz
- name: Azure login
uses: azure/login@v2
with:
Expand All @@ -82,10 +58,10 @@ jobs:
- name: Upload to Azure blob storage
shell: bash
run: |
if [ -z "${{ inputs.demo-blob-name }}" ]; then
az storage blob upload-batch --account-name reportvisionfrontend${{ inputs.deploy-env }} -d '$web' -s client-build/ --overwrite
if [ -z "" ]; then
az storage blob upload-batch --account-name reportvisionfrontenddev -d '$web' -s frontend-deploy/ --overwrite
else
az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s client-build/ --overwrite
az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s frontend-deploy/ --overwrite
fi
- name: Azure logout
shell: bash
Expand Down
75 changes: 36 additions & 39 deletions .github/workflows/build-deploy-ocr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@ name: Create, publish, deploy a OCR API image
on:
workflow_dispatch:
inputs:
tag:
description: 'Version tag for new release'
required: true

env:
REGISTRY: ghcr.io
VERSION: ${{ inputs.tag }}
deploy-env:
description: 'The environment to deploy to'
required: true
type: choice
options:
- dev
- demo
ocr-version:
description: 'Create a version for this OCR API image'
required: true

permissions:
contents: read
packages: write
attestations: write
id-token: write

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
outputs:
docker_inspect: ${{ steps.image_check.outputs.docker_inspect }}
steps:
Expand All @@ -28,7 +31,7 @@ jobs:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Lowercase the repo name
Expand All @@ -37,41 +40,35 @@ jobs:
id: image_check
run: |
echo "docker_inspect=$(
docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $?
docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ inputs.deploy-env }} > /dev/null ; echo $?
)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
- name: Build and Push backend
if: ${{ steps.image_check.outputs.docker_inspect == 1 }}
uses: ./.github/actions/build-publish-api
with:
context: ./OCR/
file: ./OCR/Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }}
docker-registry: ghcr.io
docker-pw: ${{ secrets.GITHUB_TOKEN }}
docker-username: ${{ github.actor }}
docker-tag: ${{ inputs.ocr-version }}
dockerfile-path: ./OCR/Dockerfile
docker-context-path: ./OCR/
api-name: ocr-api

deploy:
deploy-ocr-api:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
needs: build-and-push-image
environment: dev3
environment: ${{ inputs.deploy-env }}
needs: [build-and-push-image]
steps:
- uses: actions/checkout@v4
- uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Lowercase the repo name
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
- name: Deploy OCR-API
uses: ./.github/actions/deploy-api
with:
app-name: reportvision-ocr-dev3
images: '${{ env.REGISTRY }}/${{ env.REPO}}-ocr-api:${{ env.VERSION }}'

deploy-env: ${{ inputs.deploy-env }}
docker-tag: ${{ inputs.ocr-version }}
docker-registry: ghcr.io
api-name: ocr-api

0 comments on commit d4d5622

Please sign in to comment.