Skip to content

.github/workflows/scheduled-azure-teardown.yml #419

.github/workflows/scheduled-azure-teardown.yml

.github/workflows/scheduled-azure-teardown.yml #419

# This file is part of our engineering process to build and maintain this file.
# See the README markdown file for further details
on:
workflow_dispatch:
schedule:
- cron: '0 13 1 * *' # Run at 13:00 on the 1st day of the month
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
permissions:
id-token: write
contents: read
concurrency: integration_testing
jobs:
build:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/azure-dev-cli-apps:1.9.5
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
steps:
- name: Install jq tool
uses: dcarbone/install-jq-action@v2
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install Az module
run: Install-Module -Name Az -Force -AllowClobber -Scope CurrentUser -Repository PSGallery
shell: pwsh
# login to run ado commands such provision, deploy, and down
- name: Log in with Azure (Federated Credentials)
if: ${{ env.AZURE_CLIENT_ID != '' }}
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID" `
shell: pwsh
# login to run azd hooks and the QA validation script
- name: Log in with Azure CLI
if: ${{ env.AZURE_CLIENT_ID != '' }}
uses: Azure/login@v1.6.1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Set the environment
run: azd env new ${{ secrets.AZURE_ENV_NAME }}
- name: Set the subscription
run : azd env set AZURE_SUBSCRIPTION_ID ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Set the location
run : azd env set AZURE_LOCATION ${{ secrets.AZURE_LOCATION }}
- name: Set the principal type
run : azd env set AZURE_PRINCIPAL_TYPE ServicePrincipal
- name: Set AZURE_RESOURCE_GROUP
# Azure resource group is required by the AZD tool for teardown
# calculated AZURE_RESOURCE_GROUP from the templates
run : azd env set AZURE_RESOURCE_GROUP rg-${{ secrets.AZURE_ENV_NAME }}-dev-${{ secrets.AZURE_LOCATION }}-application
- name: Teardown Azure resources
continue-on-error: true
run: azd down --force --purge --no-prompt