Skip to content

Commit

Permalink
arranged frontend to deploy properly with appi connection
Browse files Browse the repository at this point in the history
Jira ticket: CAMS-417
  • Loading branch information
amorrow-flexion committed Dec 26, 2024
1 parent c7fa4ce commit 3ef1144
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
migrationFunctionName: ${{ needs.setup.outputs.migrationFunctionName }}
environment: ${{ needs.setup.outputs.ghaEnvironment }}
launchDarklyEnvironment: ${{ vars.CAMS_LAUNCH_DARKLY_ENV }}
azAppResourceGrpEncrypted: ${{ needs.setup.outputs.azResourceGrpAppEncrypted }}

deploy:
name: Cloud Resource Deployment
Expand Down
101 changes: 101 additions & 0 deletions .github/workflows/reusable-build-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Build Frontend

on:
workflow_call:
inputs:
nodeVersion:
required: true
type: string
isDeployment:
default: false
type: boolean
camsServerHostname:
required: true
type: string
camsServerPort:
required: true
type: string
camsServerProtocol:
required: true
type: string
camsBasePath:
required: true
type: string
webappName:
required: true
type: string
environment:
required: true
type: string
launchDarklyEnvironment:
required: true
type: string
azResourceGrpAppEncrypted:
required: true
type: string
jobs:
frontend:
defaults:
run:
working-directory: user-interface
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v3

- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
environment: ${{ vars.AZURE_ENVIRONMENT }}

- uses: cloudposse/github-action-secret-outputs@main
id: rgApp
with:
secret: ${{ secrets.PGP_SIGNING_PASSPHRASE }}
op: decode
in: ${{ inputs.azResourceGrpAppEncrypted }}

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.nodeVersion }}
cache: "npm"
cache-dependency-path: user-interface/package-lock.json

- name: Execute Build
run: |
pushd ../common
npm ci
popd
appiString=$(az monitor app-insights component show --app appi-${{ inputs.webappName }} -g ${{ steps.rgApp.outputs.out }} --query "connectionString" -o tsv || true)
npm ci
export CAMS_SERVER_HOSTNAME=${{ inputs.camsServerHostname }}
export CAMS_SERVER_PORT=${{ inputs.camsServerPort }}
export CAMS_SERVER_PROTOCOL=${{ inputs.camsServerProtocol }}
export CAMS_BASE_PATH=${{ inputs.camsBasePath }}
export CAMS_APPLICATIONINSIGHTS_CONNECTION_STRING="${appiString}"
export CAMS_FEATURE_FLAG_CLIENT_ID="${{ secrets.LD_DEVELOPMENT_CLIENT_ID }}"
export CAMS_LAUNCH_DARKLY_ENV="${{ inputs.launchDarklyEnvironment }}"
export CAMS_LOGIN_PROVIDER=${{ vars.CAMS_LOGIN_PROVIDER }}
export CAMS_LOGIN_PROVIDER_CONFIG='${{ vars.CAMS_LOGIN_PROVIDER_CONFIG }}'
export CAMS_INFO_SHA=${{ github.sha }}
npm run build --if-present
- name: Package
if: inputs.isDeployment
run: |
pushd ./build
zip -r ./${{ inputs.webappName }}.zip .
popd
mkdir ./artifacts
mv ./build/${{ inputs.webappName }}.zip ./artifacts/
- name: Upload Frontend Artifact
if: inputs.isDeployment
uses: actions/[email protected]
with:
name: ${{ inputs.webappName }}-build
path: user-interface/artifacts/
if-no-files-found: error
66 changes: 17 additions & 49 deletions .github/workflows/sub-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,56 +33,24 @@ on:
launchDarklyEnvironment:
required: true
type: string
azResourceGrpAppEncrypted:
required: true
type: string
jobs:
frontend:
defaults:
run:
working-directory: user-interface
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.nodeVersion }}
cache: "npm"
cache-dependency-path: user-interface/package-lock.json

- name: Execute Build
run: |
pushd ../common
npm ci
popd
npm ci
export CAMS_SERVER_HOSTNAME=${{ inputs.camsServerHostname }}
export CAMS_SERVER_PORT=${{ inputs.camsServerPort }}
export CAMS_SERVER_PROTOCOL=${{ inputs.camsServerProtocol }}
export CAMS_BASE_PATH=${{ inputs.camsBasePath }}
export CAMS_APPLICATIONINSIGHTS_CONNECTION_STRING="${{ secrets.AZ_APPINSIGHTS_WEBAPP_CONNECTION_STRING }}"
export CAMS_FEATURE_FLAG_CLIENT_ID="${{ secrets.LD_DEVELOPMENT_CLIENT_ID }}"
export CAMS_LAUNCH_DARKLY_ENV="${{ inputs.launchDarklyEnvironment }}"
export CAMS_LOGIN_PROVIDER=${{ vars.CAMS_LOGIN_PROVIDER }}
export CAMS_LOGIN_PROVIDER_CONFIG='${{ vars.CAMS_LOGIN_PROVIDER_CONFIG }}'
export CAMS_INFO_SHA=${{ github.sha }}
npm run build --if-present
- name: Package
run: |
pushd ./build
zip -r ./${{ inputs.webappName }}.zip .
popd
mkdir ./artifacts
mv ./build/${{ inputs.webappName }}.zip ./artifacts/
- name: Upload Frontend Artifact
uses: actions/[email protected]
with:
name: ${{ inputs.webappName }}-build
path: user-interface/artifacts/
if-no-files-found: error
build-frontend-predeployment:
name: Build Frontend Predeployment
uses: ./.github/workflows/reusable-build-frontend.yml
secrets: inherit # pragma: allowlist secret
with:
nodeVersion: ${{ vars.NODE_VERSION }}
camsServerHostname: ${{ inputs.apiFunctionName }}.azurewebsites.us
camsServerPort: ${{ vars.CAMS_SERVER_PORT }}
camsServerProtocol: ${{ vars.CAMS_SERVER_PROTOCOL }}
camsBasePath: ${{ vars.CAMS_BASE_PATH }}
webappName: ${{ inputs.webappName }}
environment: ${{ inputs.environment }}
launchDarklyEnvironment: ${{ vars.CAMS_LAUNCH_DARKLY_ENV }}
azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }}

backend:
defaults:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/sub-deploy-code-slot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,25 @@ on:
type: string

jobs:
build-frontend-deployment:
name: Build Frontend deployment
uses: ./.github/workflows/reusable-build-frontend.yml
secrets: inherit # pragma: allowlist secret
with:
nodeVersion: ${{ vars.NODE_VERSION }}
camsServerHostname: ${{ inputs.apiFunctionName }}.azurewebsites.us
camsServerPort: ${{ vars.CAMS_SERVER_PORT }}
camsServerProtocol: ${{ vars.CAMS_SERVER_PROTOCOL }}
camsBasePath: ${{ vars.CAMS_BASE_PATH }}
webappName: ${{ inputs.webappName }}
environment: ${{ inputs.ghaEnvironment }}
launchDarklyEnvironment: ${{ vars.CAMS_LAUNCH_DARKLY_ENV }}
azResourceGrpAppEncrypted: ${{ inputs.azResourceGrpAppEncrypted }}
isDeployment: true

deploy-code:
if: ${{ inputs.initialDeployment == 'true' }}
needs: [build-frontend-deployment]
name: Slot Code Deployment
uses: ./.github/workflows/sub-deploy-code.yml
with:
Expand All @@ -50,6 +67,7 @@ jobs:
secrets: inherit # pragma: allowlist secret

deploy-webapp-slot:
needs: [build-frontend-deployment]
runs-on: ubuntu-latest
environment: ${{ inputs.ghaEnvironment }}
steps:
Expand Down

0 comments on commit 3ef1144

Please sign in to comment.