add mongoose compatibility with documentdb #123
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: 'Terraform Infrasture Pipeline' | |
on: | |
pull_request: | |
branches: ['dev', 'main'] | |
push: | |
branches: [ 'dev', 'main' ] | |
jobs: | |
approve: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Approve | |
run: echo "All PRS need to be approved before starting automated CI" | |
github: | |
name: 'Github Actions Setup' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Branch check to determine environment | |
id: branch_check | |
run: | | |
echo "Running on branch ${{ github.ref }}" | |
if ["${{ github.ref }}" = "refs/heads/main"]; then | |
echo "::set-output name=env_name::Production" | |
else | |
echo "::set-output name=env_name::Preview" | |
fi | |
- name: Use variable setup in previous step | |
run: echo "I'm using variable ${{ steps.branch_check.outputs.env_name }}" | |
outputs: | |
env_name: ${{ steps.branch_check.outputs.env_name }} | |
terraform: | |
name: 'Terraform' | |
needs: [github] | |
runs-on: ubuntu-latest | |
environment: ${{ needs.github.outputs.env_name }} | |
permissions: | |
pull-requests: write | |
env: | |
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
backend_bucket: ${{ secrets.S3_BACKEND_BUCKET }} | |
backend_key: ${{ vars.S3_BACKEND_KEY }}] | |
region: ${{ secrets.AWS_REGION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha || github.ref }} | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2 | |
with: | |
terraform_wrapper: false | |
- name: Check current environement | |
run: | | |
echo "${{ vars.TEST_VAR }}" | |
echo $region | |
echo $backend_key | |
- name: Terraform init, format and validate | |
run: | | |
echo "** Running Terraform Init **" | |
terraform init -backend-config="bucket=$backend_bucket" -backend-config="key=$backend_key" -backend-config="region=$region" -backend-config="access_key=$aws_access_key" -backend-config="secret_key=$aws_secret_key" | |
echo "** Download local modules" | |
terraform get | |
echo "** Runing Terraform Format Check **" | |
terraform fmt | |
echo "** Running Terraform Validate **" | |
terraform validate | |
working-directory: './deployment' | |
- name: Terraform Plan And Apply | |
run: | | |
echo "** Running Terraform Plan **" | |
terraform plan -var "aws_secret_key=$aws_secret_key" -var "aws_access_key=$aws_access_key" -var "region=$region" | |
echo "** Running Terraform Apply **" | |
# terraform apply -var 'aws_secret_key=$aws_secret_key' -var 'aws_access_key=$aws_access_key' -var 'region=$region' -auto-approve | |
working-directory: './deployment' | |