Skip to content

Deploying v0.2.13 to test #110

Deploying v0.2.13 to test

Deploying v0.2.13 to test #110

Workflow file for this run

name: Deploy Test
run-name: Deploying ${{ github.ref_name }} to test
on:
push:
tags:
- "*"
env:
TF_VERSION: 0.14.7
TG_VERSION: 0.37.1
TG_SRC_PATH: terraform
TFC_WORKSPACE: test
TARGET_ENV: test
permissions:
id-token: write
contents: read
jobs:
deploy:
name: Build to Test
runs-on: ubuntu-latest
environment: test
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v3
### Install if no cache exists ###
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "yarn"
- run: yarn install --silent --frozen-lockfile
### Build if no cache exists ###
- name: Cache Build
id: cache-build
uses: actions/cache@v3
with:
path: |
**/dist
key: ${{ github.sha }}-dist
- name: Run Build
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
sed 's@localConfigEndpoint@'true'@g' src/env.js.template > src/env.js
yarn build
### Get environment variables from AWS Parameter Store ###
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE_ARN_TO_USE }}
role-duration-seconds: 900
role-session-name: parks-ar-admin-test-gh-action
role-skip-session-tagging: true
- name: Get admin variables
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: "/parks-ar-admin/s3-bucket = S3_BUCKET, /parks-ar-admin/origin-id = ORIGIN_ID"
- name: Get API variables
uses: dkershner6/aws-ssm-getparameters-action@v1
with:
parameterPairs: "/parks-ar-api/origin-domain = API_GATEWAY_ORIGIN_DOMAIN, /parks-ar-api/origin-id = API_GATEWAY_ORIGIN_ID, /parks-ar-api/gateway-path-pattern = API_GATEWAY_PATH_PATTERN"
### Upload dist to S3 ###
- name: Deploy to Test S3
env:
s3_bucket: "${{ env.S3_BUCKET }}-${{ env.TARGET_ENV }}"
dir_name: ${{ github.ref_name }}
run: |
aws s3 sync dist/bcparks-ar-admin s3://$s3_bucket/$dir_name/
### Run Terragrunt ###
- name: Setup terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: ${{ env.TF_VERSION }}
- name: Setup Terragrunt
uses: autero1/action-terragrunt@v1.3.0
with:
terragrunt_version: ${{ env.TG_VERSION }}
- name: Terragrunt Apply
working-directory: ${{ env.TG_SRC_PATH }}/${{ env.TFC_WORKSPACE }}
env:
app_version: ${{ github.ref_name }}
s3_bucket: ${{ env.S3_BUCKET }}
s3_bucket_assets: ${{ env.S3_BUCKET_ASSETS }}
origin_id: ${{ env.ORIGIN_ID }}
api_gateway_origin_domain: ${{ env.API_GATEWAY_ORIGIN_DOMAIN }}
api_gateway_origin_id: ${{ env.API_GATEWAY_ORIGIN_ID }}
api_gateway_path_pattern: ${{ env.API_GATEWAY_PATH_PATTERN }}
origin_id_assets: ${{ env.ORIGIN_ID_ASSETS }}
run: terragrunt apply -auto-approve --terragrunt-non-interactive -var target_aws_account_id=${{ vars.ACCOUNT_ID }} -var target_env=test
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
PATHS: "/*"
alert-if-failure:
if: ${{ always() && (needs.deploy.result=='failure')}}
runs-on: ubuntu-latest
needs: [deploy]
steps:
- name: Send alert if building admin-test fails.
id: failure_alert
run: |
curl -X POST -H 'Content-Type: application/json' --data '{"workflow":"${{github.workflow}}","repo":"${{github.repository}}"}' https://chat.developer.gov.bc.ca/hooks/${{ secrets.ROCKETCHAT_TOKEN }}