-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (49 loc) · 1.96 KB
/
delete-review-app.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Delete Review App
on:
pull_request:
types: [closed]
branches: [main]
jobs:
delete-review-app:
name: Delete Review App ${{ github.event.pull_request.number }}
concurrency: deploy_review_${{ github.event.pull_request.number }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
runs-on: ubuntu-latest
environment: review
steps:
- uses: actions/checkout@v4
- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.0
terraform_wrapper: false
- name: Set environment variables
run: |
state_file_name=terraform-${{ github.event.pull_request.number }}.tfstate
echo "TF_STATE_FILE=$state_file_name" >> $GITHUB_ENV
state_file_status=$(az storage blob list -c afqts-tfstate \
--account-name "s189t01afqtstfstatervsa" \
--prefix $state_file_name --query "[].name" -o tsv)
if [ -n "$state_file_status" ]; then
echo "TF_STATE_EXISTS=true" >> $GITHUB_ENV
fi
- uses: DFE-Digital/github-actions/set-kubelogin-environment@master
if: env.TF_STATE_EXISTS == 'true'
with:
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
- name: Destroy Terraform
if: env.TF_STATE_EXISTS == 'true'
id: destroy-terraform
shell: bash
run: make ci review terraform-destroy
env:
TF_VAR_azure_sp_credentials_json: ${{ secrets.AZURE_CREDENTIALS }}
DOCKER_IMAGE: "ghcr.io/dfe-digital/apply-for-qualified-teacher-status:no-tag"
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
- name: Delete Terraform state file
if: env.TF_STATE_EXISTS == 'true'
run: |
az storage blob delete -c afqts-tfstate --name ${{ env.TF_STATE_FILE }} \
--account-name "s189t01afqtstfstatervsa"