Skip to main content

GitHub Actions

Reference Azure

DOCUMENT CATEGORY: Reference SCOPE: GitHub Actions CI/CD workflows PURPOSE: Document GitHub Actions for Azure Local deployments MASTER REFERENCE: GitHub Actions Documentation

Status: Active


Overview​

GitHub Actions workflow for Azure Local deployments. This is a sample equivalent of the primary GitLab CI/CD pipeline, adapted for GitHub-hosted and self-hosted runners with environment protection rules.

Workflow​

File: pipelines/github-actions/azure-local-deploy.yml
Copy to: .github/workflows/azure-local-deploy.yml in your repository

Jobs​

JobRunnerTriggerDescription
terraform-validateubuntu-latestAuto (push/PR)Terraform init, validate, fmt check
ansible-lintubuntu-latestAuto (push/PR)Ansible lint, syntax check
terraform-planubuntu-latestAuto (main only)Terraform plan with artifact upload
terraform-applyubuntu-latestManual (environment approval)Terraform apply from plan artifact
configure-onpremself-hosted, azurelocalAfter applyAD prep, OS config, Arc registration
configure-operationsself-hosted, azurelocalAfter on-premMonitoring, WAC, management VMs

Triggers​

on:
push:
branches: [main]
paths: ['src/terraform/**', 'src/ansible/**', 'config/variables/**']
pull_request:
branches: [main]
workflow_dispatch: # Manual trigger with deploy_target input

Setup​

1. Repository Secrets​

SecretDescription
ARM_CLIENT_IDService Principal Application ID
ARM_CLIENT_SECRETService Principal Secret
ARM_TENANT_IDAzure AD Tenant ID
ARM_SUBSCRIPTION_IDTarget Subscription ID

2. Environment Protection​

Create a production environment with required reviewers for the terraform-apply job.

3. Self-Hosted Runner​

Register a runner with labels self-hosted and azurelocal that has network access to on-premises infrastructure.

# On the runner machine:
./config.sh --url https://github.com/YOUR_ORG/YOUR_REPO \
--token YOUR_TOKEN \
--labels azurelocal,self-hosted

4. Deploy Workflow​

cp pipelines/github-actions/azure-local-deploy.yml .github/workflows/
git add .github/workflows/azure-local-deploy.yml
git commit -m "Add Azure Local deployment workflow"
git push

Key Features​

  • OIDC Authentication: Uses id-token: write permission for keyless Azure auth
  • Environment Protection: Manual approval via GitHub environment rules
  • Artifact Passing: Terraform plan artifact uploaded/downloaded between jobs
  • Self-Hosted Runner: On-prem config stages run on runner with network access
  • Path Filtering: Only triggers on changes to IaC or config files

OS Configuration Workflow​

File: pipelines/github/os-configuration.yml (copy to .github/workflows/os-configuration.yml). It runs Invoke-AzureLocalOsConfiguration.ps1 and nothing else.

JobDescription
planRead only. Publishes the plan report and the wipe list as an artifact and in the job summary
applyRuns for mode Apply only, after a reviewer of the environment azure-local-os-configuration approves it. The reviewer reads the plan job's summary, the wipe list included

Settings are variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_SUBSCRIPTION_ID) of an app registration with a federated credential for the repository and the environment, so there is no client secret. The runner needs a route to the nodes' management network for PowerShell remoting. See Automated OS configuration.

ARM Validate and Deploy Workflow​

File: pipelines/github-actions/arm-deployment.yml (copy to .github/workflows/arm-deployment.yml).

JobDescription
preconditionsRead only. Generates the ARM parameters and runs every precondition. Always runs
validateRuns for mode Validate and ValidateAndDeploy
deployRuns for ValidateAndDeploy and Deploy, only after a reviewer of the environment azure-local-deploy approves. It re-checks every precondition and that these parameters validated. resume resubmits a failed Deploy

Inputs: mode (Plan, Validate, ValidateAndDeploy, Deploy), infrastructure_file, os_configuration_run_id (the artifact os-configuration-report of the OS configuration workflow) or os_configuration_report, handoff_file, resume, acknowledge_known_issues. One ARM deployment runs at a time per repository. Details: ARM Validate and Deploy automation.

Repository​

Source: azurelocal-toolkit/pipelines/github-actions/


PreviousUpNext
GitLab CI/CDPart 2: CI/CD PipelinesAzure DevOps Pipelines