-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (31 loc) · 1.01 KB
/
terraform-infra-destroy.yaml
File metadata and controls
40 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Destroy Infrastructure
on:
push:
branches:
- 'destroy/**'
jobs:
terraform-destroy:
runs-on: ubuntu-latest
env:
TF_VAR_db_admin_password: ${{ secrets.DB_ADMIN_PASSWORD }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Parse environment from branch
id: env
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
ENV_NAME="${BRANCH_NAME#destroy/}"
echo "env_name=$ENV_NAME" >> $GITHUB_OUTPUT
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
run: terraform init
working-directory: terraform/environments/${{ steps.env.outputs.env_name }}
- name: Terraform Destroy
run: terraform destroy -auto-approve -var-file="terraform.tfvars"
working-directory: terraform/environments/${{ steps.env.outputs.env_name }}