Skip to content

.github/workflows/scheduled-azure-dev.yml #647

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

.github/workflows/scheduled-azure-dev.yml #647

# 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:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
schedule:
- cron: '0 12 1 * *' # Run at 12: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
- name: Check configuration
if: ${{ env.AZURE_CLIENT_ID == '' }}
run: echo "AZURE_CLIENT_ID are not available."
# 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
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd env new ${{ secrets.AZURE_ENV_NAME }}
- name: Set the subscription
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd env set AZURE_SUBSCRIPTION_ID ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Set the location
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd env set AZURE_LOCATION ${{ secrets.AZURE_LOCATION }}
- name: Set the principal type
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd env set AZURE_PRINCIPAL_TYPE ServicePrincipal
- name: Azure Deploy
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd up
- name: QA - Validate Deployment
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : ./testscripts/call-validate-deployment.sh
- name: Teardown Azure resources
if: ${{ env.AZURE_CLIENT_ID != '' }}
run : azd down --force --purge --no-prompt