Merge pull request #11 from bcgov/10-create-basic-terraform-and-terra… #7
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
name: ci | |
on: | |
#workflow_dispatch: | |
push: | |
branches: [main] | |
env: | |
TF_VERSION: 1.0.5 | |
environment: dev | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: checkout the repo and building the Backend | |
uses: actions/checkout@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: ${{ secrets.TERRAFORM_DEPLOY_ROLE_ARN }} | |
aws-region: ca-central-1 | |
- name: building the backend | |
run: | | |
cd server/lambda | |
npm install | |
- name: Deploying back-end using terraform | |
run: | | |
cd server | |
cat <<EOF > backend.hcl | |
bucket = "${{ vars.S3_BACKEND_NAME }}" | |
key = "${{ vars.LICENCEPLATE }}/${{ env.environment }}/serverless-app.tfstate" | |
dynamodb_table = "terraform-remote-state-lock-${{ vars.LICENCEPLATE }}" | |
EOF | |
terraform init -backend-config=backend.hcl | |
terraform apply -auto-approve | |
- name: Building front-end and deploying Frontend using terraform | |
run: | | |
cd server | |
terraform output > ../client/.env | |
cd ../client | |
npm install | |
CI=false npm run build | |
cat <<EOF > backend.hcl | |
bucket = "${{ vars.S3_BACKEND_NAME }}" | |
key = "${{ vars.LICENCEPLATE }}/${{ env.environment }}/serverless-app.tfstate" | |
dynamodb_table = "terraform-remote-state-lock-${{ vars.LICENCEPLATE }}" | |
EOF | |
terraform init -backend-config=backend.hcl | |
terraform apply -auto-approve |