Skip to content

Butler DEV VPC Peering to PanDa #63

Butler DEV VPC Peering to PanDa

Butler DEV VPC Peering to PanDa #63

# Deploys Butler Integration VPC Peering with Terraform
name: 'Butler DEV VPC Peering to PanDa'
on:
pull_request:
paths:
- 'environment/deployments/butler-repo/env/dev-vpcpeer2.tfvars'
push:
branches:
- main
paths:
- 'environment/deployments/butler-repo/env/dev-vpcpeer2.tfvars'
schedule:
- cron: 25 2 * * *
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
working-directory: ./environment/deployments/butler-repo/vpc_peering
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v3
# gcp auth
- name: GCP login
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
# gcloud setup
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
skip_install: true
# Installs terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.9.5
# Checks for proper formatting in terraform code
- name: Terraform Fmt
run: terraform fmt
# Initialize a new or existing terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init -backend-config=bucket=${{ secrets.TERRAFORM_STATE_BUCKET }} -backend-config=prefix=butler-repo/dev/vpc_peer2
# Checks that all terraform configuration files adhere to a canonical format
- name: Terraform Validate
run: terraform validate
# Generates an execution plan for terraform
- name: Terraform Plan
id: plan
run: terraform plan -var-file=../env/dev-vpcpeer2.tfvars -no-color ${{ github.event_name == 'schedule' && '-detailed-exitcode' || '' }}
# On push to main, build or change infrastructure according to terraform configuration files
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -var-file=../env/dev-vpcpeer2.tfvars -refresh=false -auto-approve
- name: Report status
if: failure() && github.ref == 'refs/heads/main'
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ job.status }}
notify_when: failure
notification_title: 'idf_deploy: Periodic plan for {workflow} failed'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_ALERT_WEBHOOK }}