-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (35 loc) · 1.07 KB
/
destroy.yml
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 Terraform resources
on:
pull_request:
branches: [master]
types: [closed]
jobs:
destroy:
name: Destroy Terraform resources
runs-on: ubuntu-latest
env:
TF_VAR_my_name: ${{ github.head_ref }}
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }}
ARM_USE_OIDC: 'true'
permissions:
contents: read
id-token: write
environment: prod
defaults:
run:
working-directory: 'terraform'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
- name: Init Terraform
run: terraform init
- name: Destroy resources and delete workspace
run: |
(terraform workspace select "$TF_VAR_my_name" && \
terraform destroy -auto-approve && \
terraform workspace select default && \
terraform workspace delete "$TF_VAR_my_name") || echo 'No workspace to destroy'