-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make reusable app deployment workflow
- Loading branch information
1 parent
ef40759
commit cc00466
Showing
2 changed files
with
87 additions
and
64 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Deploy application to AWS | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment_name: | ||
description: 'The name of the environment to deploy to' | ||
required: true | ||
type: string | ||
app_env: | ||
required: true | ||
description: 'The APP env separates between AWS ENV and Actual APP, since AWS dev is where PR, and TEST is deployed' | ||
type: string | ||
|
||
env: | ||
AWS_REGION: ca-central-1 | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: write # This is required for actions/checkout | ||
packages: write | ||
pull-requests: write | ||
|
||
jobs: | ||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploy-db: | ||
name: Deploys Database | ||
uses: ./.github/workflows/.aws-deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name }} | ||
command: apply | ||
working_directory: database | ||
app_env: ${{ inputs.app_env }} | ||
secrets: inherit | ||
deploy-api: | ||
name: Deploys API | ||
needs: [deploy-db] | ||
uses: ./.github/workflows/.aws-deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name }} | ||
command: apply | ||
working_directory: api | ||
tag: ${{ needs.vars.outputs.pr }} | ||
app_env: ${{ inputs.app_env }} | ||
secrets: inherit | ||
deploy-cloudfront: | ||
name: Deploys Cloudfront | ||
uses: ./.github/workflows/.aws-deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name }} | ||
command: apply | ||
working_directory: frontend | ||
app_env: ${{ inputs.app_env }} | ||
secrets: inherit | ||
build-ui: | ||
name: Builds UI | ||
needs: [deploy-api, deploy-cloudfront] | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
cache: 'npm' | ||
cache-dependency-path: frontend/package-lock.json | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
- name: Build And Update UI (CF) | ||
working-directory: frontend | ||
env: | ||
VITE_API_BASE_URL: ${{ needs.deploy-api.outputs.API_GW_URL }}/api | ||
S3_BUCKET_ARN: ${{ needs.deploy-cloudfront.outputs.S3_BUCKET_ARN }} | ||
CF_DISTRIBUTION_ID: ${{ needs.deploy-cloudfront.outputs.CF_DISTRIBUTION_ID }} | ||
run: | | ||
npm run deploy | ||
aws s3 sync --delete ./dist s3://$(echo "$S3_BUCKET_ARN" | cut -d: -f6) | ||
aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*" |
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