generated from bcgov/quickstart-openshift
-
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.
Merge pull request #11 from bcgov/feat/test-prod-deploy
feat: PR based testing and deploy to test
- Loading branch information
Showing
16 changed files
with
298 additions
and
192 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,112 @@ | ||
name: .Deploy to Aws | ||
on: | ||
workflow_call: | ||
inputs: | ||
### Required | ||
environment_name: | ||
description: 'The name of the environment to deploy to' | ||
required: true | ||
default: 'dev' | ||
type: string | ||
command: | ||
description: 'The terragrunt command to run' | ||
required: true | ||
default: 'apply' | ||
type: string | ||
working_directory: | ||
description: 'The working directory to run the command in' | ||
required: true | ||
default: 'database' | ||
type: string | ||
tag: | ||
description: 'The tag of the containers to deploy' | ||
default: 'latest' | ||
type: string | ||
required: false | ||
app_env: | ||
required: false | ||
type: string | ||
description: 'The APP env separates between AWS ENV and Actual APP, since AWS dev is where PR, and TEST is deployed' | ||
AWS_DEPLOY_ROLE_ARN: | ||
description: 'The ARN of the role to assume to deploy to AWS' | ||
required: true | ||
type: string | ||
AWS_LICENSE_PLATE: | ||
description: 'The license plate of the car to deploy to AWS, it is without the `-env`' | ||
type: string | ||
required: true | ||
outputs: | ||
API_GW_URL: | ||
value: ${{ jobs.deploy-api.outputs.API_GW_URL }} | ||
S3_BUCKET_ARN: | ||
value: ${{ jobs.deploy-cloudfront.outputs.S3_BUCKET_ARN }} | ||
CF_DOMAIN: | ||
value: ${{ jobs.deploy-cloudfront.outputs.CF_DOMAIN }} | ||
CF_DISTRIBUTION_ID: | ||
value: ${{ jobs.deploy-cloudfront.outputs.CF_DISTRIBUTION_ID }} | ||
env: | ||
AWS_REGION: ca-central-1 | ||
jobs: | ||
|
||
# https://github.com/bcgov/quickstart-openshift-helpers | ||
deploy-db: | ||
name: Deploys Database | ||
uses: ./.github/workflows/.deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name}} | ||
command: apply | ||
working_directory: database | ||
app_env: ${{ inputs.environment_name}} # Database | ||
AWS_DEPLOY_ROLE_ARN: ${{ inputs.AWS_DEPLOY_ROLE_ARN }} | ||
AWS_LICENSE_PLATE: ${{ inputs.AWS_LICENSE_PLATE }} | ||
deploy-api: | ||
name: Deploys API | ||
needs: [deploy-db] | ||
uses: ./.github/workflows/.deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name}} | ||
command: apply | ||
working_directory: api | ||
tag: ${{ inputs.tag }} | ||
app_env: ${{ inputs.app_env}} | ||
AWS_DEPLOY_ROLE_ARN: ${{ inputs.AWS_DEPLOY_ROLE_ARN }} | ||
AWS_LICENSE_PLATE: ${{ inputs.AWS_LICENSE_PLATE }} | ||
deploy-cloudfront: | ||
name: Deploys Cloudfront | ||
uses: ./.github/workflows/.deployer.yml | ||
with: | ||
environment_name: ${{ inputs.environment_name}} | ||
command: apply | ||
working_directory: frontend | ||
app_env: ${{ inputs.app_env}} | ||
AWS_DEPLOY_ROLE_ARN: ${{ inputs.AWS_DEPLOY_ROLE_ARN }} | ||
AWS_LICENSE_PLATE: ${{ inputs.AWS_LICENSE_PLATE }} | ||
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: ${{ inputs.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
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
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,31 @@ | ||
name: .Tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
e2e: | ||
name: E2E Tests | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Run Docker compose | ||
run: docker compose up -d --wait | ||
- uses: actions/setup-node@v4 | ||
name: Setup Node | ||
with: | ||
node-version: 22 | ||
cache: 'npm' | ||
cache-dependency-path: frontend/package-lock.json | ||
- name: Install dependencies | ||
run: | | ||
npm ci | ||
npx playwright install --with-deps | ||
- name: Run Tests | ||
env: | ||
E2E_BASE_URL: http://localhost:3000 | ||
CI: 'true' | ||
run: | | ||
npx playwright test --project="chromium" --reporter=blob |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.