GitHub Actions
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
| Job | Runner | Trigger | Description |
|---|---|---|---|
terraform-validate | ubuntu-latest | Auto (push/PR) | Terraform init, validate, fmt check |
ansible-lint | ubuntu-latest | Auto (push/PR) | Ansible lint, syntax check |
terraform-plan | ubuntu-latest | Auto (main only) | Terraform plan with artifact upload |
terraform-apply | ubuntu-latest | Manual (environment approval) | Terraform apply from plan artifact |
configure-onprem | self-hosted, azurelocal | After apply | AD prep, OS config, Arc registration |
configure-operations | self-hosted, azurelocal | After on-prem | Monitoring, 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
| Secret | Description |
|---|---|
ARM_CLIENT_ID | Service Principal Application ID |
ARM_CLIENT_SECRET | Service Principal Secret |
ARM_TENANT_ID | Azure AD Tenant ID |
ARM_SUBSCRIPTION_ID | Target 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: writepermission 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.
| Job | Description |
|---|---|
plan | Read only. Publishes the plan report and the wipe list as an artifact and in the job summary |
apply | Runs 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).
| Job | Description |
|---|---|
preconditions | Read only. Generates the ARM parameters and runs every precondition. Always runs |
validate | Runs for mode Validate and ValidateAndDeploy |
deploy | Runs 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/
Navigation
| Previous | Up | Next |
|---|---|---|
| GitLab CI/CD | Part 2: CI/CD Pipelines | Azure DevOps Pipelines |