-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (35 loc) · 1.28 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
41
---
name: "Terraform: destroy"
on:
delete:
jobs:
destroy:
if: github.event.ref != 'main' && github.event.ref != 'default'
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
steps:
- uses: actions/checkout@v2
- name: Use branch workspace (feature branch)
run: |
echo "WORKSPACE=${{ github.event.ref }}" >> $GITHUB_ENV
# for some reason this (dynamic) JSON string is not possible directly in the `with:` block
- name: Put variables in env var
run: |
echo "VARIABLES_JSON={\"git_branch\": \"${GITHUB_REF#refs/heads/}\", \"platform_tools_artifact_filename\": \"platform_tools.egg\"}" >> $GITHUB_ENV
- uses: Pararius/[email protected]
with:
google_credentials: ${{ secrets.GCLOUD_AUTH_TF_RW }}
terraform_directory: ./terraform
terraform_do_apply: false
terraform_do_destroy: true
terraform_variables: ${{ env.VARIABLES_JSON }}
terraform_workspace: ${{ env.WORKSPACE }}
- name: Send alert for failing destroy
uses: ravsamhq/notify-slack-action@v1
with:
status: ${{ job.status }}
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}