Purge AKS cluster #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |