-
Notifications
You must be signed in to change notification settings - Fork 2
39 lines (33 loc) · 1.62 KB
/
purge-cluster.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
name: Purge AKS cluster
on:
workflow_dispatch:
jobs:
purge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: latest
- name: Login to Azure
run: az login --service-principal -u ${{ secrets.CLIENT_ID }} -p ${{ secrets.CLIENT_SECRET }} --tenant ${{ secrets.AZURERM_TENANT_ID }}
- name: Terraform Apply
working-directory: ./iac
run: |
export ARM_CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}
export ARM_CLIENT_ID=${{ secrets.CLIENT_ID }}
export TF_VAR_subscription_id=${{ secrets.AZURERM_SUBSCRIPTION_ID }}
export TF_VAR_tenant_id=${{ secrets.AZURERM_TENANT_ID }}
export TF_CLI_ARGS_init=" -backend-config=\"resource_group_name=${{ secrets.AZURERM_RESOURCE_GROUP_NAME }}\" -backend-config=\"key=${{ secrets.KEY }}.tfstate\" -backend-config=\"storage_account_name=${{ secrets.AZURERM_STORAGE_ACCOUNT_NAME }}\" -backend-config=\"container_name=tfbootstrapadmin\" -backend-config=\"subscription_id=${{ secrets.AZURERM_SUBSCRIPTION_ID }}\" -backend-config=\"tenant_id=${{ secrets.AZURERM_TENANT_ID }}\" "
terraform init
terraform plan -out=tfplan.bin -input=false
terraform destroy -auto-approve || true
terraform destroy -auto-approve || true
terraform destroy -auto-approve || true
- name: Logout of Azure
if: always()
run: az logout