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. No value of a deployment is written in a workflow file: every value a job needs is a key of infrastructure.yml, and Task 05 of the CI/CD setup (Set-CicdVariables.ps1) sets it as a repository variable (vars.NAME; the sign-in values also per environment) (Task 05). Run Task 05 again after you change the file.
pipelines/github-actions/ is the only folder of GitHub deployment workflows in the toolkit: azure-local-deploy.yml, cicd-infra.yml, discovery.yml, os-configuration.yml, pre-cluster-verification.yml, arm-deployment.yml, post-deployment.yml, the validation workflow validation.yml and the day 2 workflows day2-check-updates.yml, day2-update.yml, day2-node-maintenance.yml and day2-cluster-operations.yml. The toolkit's own .github/workflows folder holds one workflow of the toolkit repository itself (deploy-docs.yml), not a deployment pipeline. The old archive folder of GitHub workflows is gone: its workflows were the toolkit's own repository checks, not deployment pipelines.
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 |
|---|---|---|---|
config-validate | [self-hosted, AZL_RUNNER_OS, AZL_RUNNER_LABEL] | By hand | Test-InfrastructureFile.ps1 on the master file (the same check as GitLab config:validate and Azure DevOps CheckInfrastructureFile) |
terraform-validate | ubuntu-latest | By hand | Terraform init, validate, fmt check |
ansible-lint | ubuntu-latest | By hand | Ansible lint, syntax check |
terraform-plan | ubuntu-latest | By hand (default branch only) | Writes the variable files, Terraform plan with artifact upload |
terraform-apply | [self-hosted, AZL_RUNNER_OS, AZL_RUNNER_LABEL] | Manual (environment approval) | Terraform apply from plan artifact |
configure-onprem | [self-hosted, AZL_RUNNER_OS, AZL_RUNNER_LABEL] | After apply | Playbooks 05 (domain controllers), 01 (AD preparation), 02 (OS configuration), 03 (Arc registration) |
configure-operations | [self-hosted, AZL_RUNNER_OS, AZL_RUNNER_LABEL] | After on-prem | Playbook 04 (monitoring) |
The workflow names no runner label, runner OS, environment, tool version or infrastructure file. ubuntu-latest is the vendor's label of its hosted image, used only by the jobs that validate and plan. The apply and on-premises jobs run in the environment in AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT (devops.pipelines.environments.terraform_deployment). One deployment runs at a time per repository (concurrency group).
Every Terraform and Ansible job writes its inputs from the infrastructure file first (config/variables/scripts/New-IacVariableFiles.ps1): the Terraform variables into the job's temporary directory (terraform plan -var-file=<dir>/terraform/azure-local/terraform.tfvars.json), the Ansible hosts.yml, group_vars and host_vars into src/ansible/inventory (git-ignored there). They hold subscription IDs and names, so they are never committed or uploaded. Playbook 02 runs Invoke-AzureLocalOsConfiguration.ps1 on the runner with -e azurelocal_os_configuration_infrastructure_file=<AZL_INFRASTRUCTURE_FILE>.
Triggers
on:
workflow_dispatch:
The workflow is started by hand, like the same pipeline on GitLab (the web form or the API) and Azure DevOps (trigger: none and pr: none): one design on the three platforms (owner directive D126), and a deployment is a decision, not a push. Plan, apply and the configuration run only on the default branch of the repository (github.event.repository.default_branch).
Setup
1. Repository Variables
Task 05 sets each variable below from its key. Every run step is PowerShell 7.
| Variable | Key in infrastructure.yml |
|---|---|
ARM_CLIENT_ID | azure.automation_identity.client_id (else the app registration Task 01 made) |
ARM_TENANT_ID | azure.tenant_id |
ARM_SUBSCRIPTION_ID | azure.subscription_id |
AZL_AUTH_METHOD | devops.authentication.method: oidc (a federated credential, no secret) or client_secret |
ARM_CLIENT_SECRET (a secret, only with client_secret) | devops.authentication.client_secret (Task 05 reads it from Key Vault) |
AZL_RUNNER_OS, AZL_RUNNER_LABEL | devops.runners[].os_type of the general runner and devops.pipelines.runner_label |
AZL_ENVIRONMENT_TERRAFORM_DEPLOYMENT, AZL_ENVIRONMENT_OS_CONFIGURATION, AZL_ENVIRONMENT_ARM_DEPLOYMENT, AZL_ENVIRONMENT_CICD_INFRA, AZL_ENVIRONMENT_OPERATIONS | devops.pipelines.environments.* (operations gates every validation and day 2 job that changes the cluster) |
AZL_INFRASTRUCTURE_FILE | devops.pipelines.infrastructure_file |
AZL_HANDOFF_PATH | devops.pipelines.handoff_path |
TF_BACKEND_RG, TF_BACKEND_SA, TF_BACKEND_CONTAINER, TF_BACKEND_KEY | devops.state.resource_group, .storage_account, .container, .azure_local_key |
AZL_TERRAFORM_VERSION, AZL_PYTHON_VERSION, AZL_ANSIBLE_CORE_VERSION, AZL_ANSIBLE_LINT_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_KEYVAULT_VERSION | devops.pipelines.tool_versions.terraform, .python, .ansible_core, .ansible_lint, .az_powershell, .powershell_yaml, .az_keyvault |
AZL_VALIDATE_JOB_TIMEOUT_MINUTES, AZL_DEPLOY_JOB_TIMEOUT_MINUTES | deployment.validate_timeout_minutes, deployment.deploy_timeout_minutes, each plus 60 minutes |
AZL_RUNNER_SSH_PUBLIC_KEY | devops.runners[].admin_ssh_public_key of the Linux runner |
Sign-in. With oidc, azure/login takes client-id, tenant-id and subscription-id, and Terraform runs with ARM_USE_OIDC=true. With client_secret, azure/login takes creds from ARM_CLIENT_SECRET and Terraform reads ARM_CLIENT_SECRET. A managed identity of the runner is not a sign-in method of the pipelines.
State. The terraform init steps pass the four TF_BACKEND_* variables to the azurerm backend, which signs in to the storage account with Microsoft Entra ID (use_azuread_auth=true).
2. Environment Protection
Create the environment that devops.pipelines.environments.terraform_deployment names, with required reviewers (Task 04 of the CI/CD setup creates it). It gates the terraform-apply job and the on-premises jobs. The validation and day 2 workflows use the environment of devops.pipelines.environments.operations (below).
No change without an approval environment
Every job of the toolkit's workflows that changes something runs in the environment named by an AZL_ENVIRONMENT_* repository variable. While that variable is empty, the job does not run without an approval. Instead the job approval-environment-not-set runs. It fails with a message that names the variable and its devops.pipelines.environments.* key, and nothing is sent to any machine. This holds for the OS configuration, CI/CD infrastructure, Terraform, ARM deployment, validation (the storage load test) and day 2 workflows. The read-only jobs run as before. It is the same rule as the Azure DevOps stage ApprovalEnvironmentNotSet. Run Task 05 to set the variables.
3. Self-Hosted Runner
Register a runner that has network access to on-premises infrastructure. Give it the label of devops.pipelines.runner_label (an entry of devops.runners[].labels). Task 06 of the CI/CD setup deploys the runners.
# On the runner machine. azure-local is the example value of devops.pipelines.runner_label.
./config.sh --url https://github.com/YOUR_ORG/YOUR_REPO \
--token YOUR_TOKEN \
--labels azure-local
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
- Sign-in by
AZL_AUTH_METHOD: OIDC (id-token: write, no secret) or a client secret read from Key Vault by Task 05 - 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
- Started by hand:
workflow_dispatchonly, the same as GitLab and Azure DevOps
OS Configuration Workflow
File: pipelines/github-actions/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 |
confirm-storage-wipe | Runs for mode Apply only when os_configuration.clear_storage is true in the master file: a second, separate approval in the environment in AZL_ENVIRONMENT_OS_CONFIGURATION_CLEAR_STORAGE (devops.pipelines.environments.os_configuration_clear_storage); it prints the wipe list. While that variable is empty, the job storage-wipe-approval-environment-not-set fails instead and apply does not run. The same two approvals as Azure DevOps and GitLab (D126) |
apply | Runs for mode Apply only, after a reviewer of the environment in AZL_ENVIRONMENT_OS_CONFIGURATION (devops.pipelines.environments.os_configuration) approves it, and for a wipe only after the second approval. The reviewer reads the plan job's summary, the wipe list included |
Inputs: mode (Plan or Apply, default Plan), handoff_run_id (the artifact ztp-handoff of a ZTP run, in place of AZL_HANDOFF_PATH) approved_bootstrap (approves the one-time WinRM bootstrap of os_configuration.remoting.bootstrap_transport for this run) and confirm_wipe_deployed_cluster (lets the wipe touch a node of a deployed cluster for this run). Repository variables set by Task 05: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (oidc with a federated credential for the repository and the environment, or client_secret with the secret ARM_CLIENT_SECRET), AZL_RUNNER_OS, AZL_RUNNER_LABEL, AZL_ENVIRONMENT_OS_CONFIGURATION, AZL_INFRASTRUCTURE_FILE, AZL_HANDOFF_PATH, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION. The transport, the storage wipe and the bootstrap route come from the master file; the workflow overrides none of them. The runner needs a route to the nodes' management network for PowerShell remoting. See Automated OS configuration.
Discovery Workflow
File: pipelines/github-actions/discovery.yml (copy to .github/workflows/discovery.yml). It runs scripts/common/discovery/Invoke-AzlDiscoveryRun.ps1 and nothing else.
| Job | Description |
|---|---|
discover | Read only. Runs the discovery steps of the chosen scope, then publishes the report as the artifact discovery-report and summary.md as the job summary. There is no approval: nothing in the run changes a BMC, a node, Azure or Active Directory |
Inputs:
| Input | Meaning |
|---|---|
scope | all (default: hardware inventory, Azure tenant and Active Directory), hardware (Get-HardwareInventory.ps1, any maker, over the standard Redfish API), dell (Invoke-HardwareDiscovery.ps1, Dell iDRAC only, with the proposal for nodes[]), tenant (Inventory-AzureTenant.ps1) or directory (Get-OnPremInventory.ps1) |
management_port | Scope dell: the management port of every node, by suggested name or MAC. Empty: the MAC already in the file |
write_back | Scope dell: put the serial numbers and MAC addresses found into a copy of the master file, in the artifact (write-back/, with write-back/changes.txt). The file in the repository is not changed and nothing is committed: review the copy and commit it through a pull request of your own |
include_rbac | Scope tenant: also record the role assignments |
The artifact holds discovery-report.json (what ran, the exit code of each step, the files each step wrote, the verdict), summary.md and a folder per step. It is published even when a step fails, and kept for 30 days. The run fails when a step fails. The artifact holds serial numbers and MAC addresses.
Repository variables set by Task 05: ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD (and the secret ARM_CLIENT_SECRET with client_secret), AZL_RUNNER_OS, AZL_RUNNER_LABEL, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION, AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION. The identity needs Reader on the subscriptions of the tenant inventory and Get on the Key Vault secrets of the BMC login.
The BMC login is never in the workflow or in a variable. It is the secret reference in infrastructure.yml (hardware.bmc, or nodes[].bmc), and the toolkit secret resolver reads it from Key Vault at run time with the Azure sign-in of the job.
The job runs on the general self-hosted runner. It needs a route to the BMC addresses (HTTPS, TCP 443) and, for the directory step, the ActiveDirectory module (RSAT) on a domain-joined runner. A step the runner cannot do fails with its reason in the report. See Task 02: Hardware Discovery.
Pre-cluster Verification Workflow
File: pipelines/github-actions/pre-cluster-verification.yml (copy to .github/workflows/pre-cluster-verification.yml). It runs scripts/deploy/04-cluster-deployment/phase-05-cluster-deployment/Invoke-AzureLocalPreClusterVerification.ps1 and nothing else. It is the gate after the OS configuration and before the ARM Validate: the ARM run refuses to go on without a passing, current result of it for the same master file.
| Job | Description |
|---|---|
verify | Read only. Mode Plan (what would be checked, offline) or Verify (every check, against Azure, Active Directory and the nodes) |
verify-with-changes | Runs instead of verify when the input fix or install_environment_checker is set, and only after a reviewer of the environment in AZL_ENVIRONMENT_ARM_DEPLOYMENT (devops.pipelines.environments.arm_deployment) approves. fix registers the mandatory resource providers that are not registered (Azure side only). install_environment_checker puts the Environment Checker on the nodes for this run and removes it again at the end |
Inputs: mode (Plan or Verify, default Plan), os_configuration_run_id (the artifact os-configuration-report of the OS configuration workflow) or os_configuration_report (a repository path), handoff_file (optional), accept_skipped (ids of checks that may stay Skipped, comma separated; the report records that you accepted them), allow_revalidate, fix, install_environment_checker.
The run fails when the verdict is not Pass (exit code 1: a Failed or Skipped check blocks; 3: a partial run). Each job publishes report.json, summary.md and the event feed as the artifact pre-cluster-verification (kept for 30 days) and in the job summary.
The workflow passes no -ReportDirectory. The script writes its result where the ARM run reads it: deployment.pre_cluster_verification_report_directory, else arm-report/verification/live in the environment data folder of the master file. The artifact is only a copy. Run the ARM workflow on the same runner, or set deployment.pre_cluster_verification_report_directory to a folder both runs reach.
The identity needs Reader for the checks (Owner or Contributor for fix) and Get on the Key Vault secrets of the local administrator and the LCM user. The runner needs a route to the nodes (WinRM, TCP 5985 or 5986), to a domain controller (LDAP, TCP 389) and to the DNS servers of the file. A check the runner cannot ask is Skipped with its reason, and a Skipped check blocks the verdict until you accept its id. Details: Pre-cluster verification gate.
ARM Validate and Deploy Workflow
File: pipelines/github-actions/arm-deployment.yml (copy to .github/workflows/arm-deployment.yml). Run it after a passing pre-cluster verification, on the same runner unless the report directory is shared.
| 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 in AZL_ENVIRONMENT_ARM_DEPLOYMENT (devops.pipelines.environments.arm_deployment) approves. It re-checks every precondition and that these parameters validated. resume resubmits a failed Deploy |
The infrastructure file is the repository variable AZL_INFRASTRUCTURE_FILE, not an input. The Validate and Deploy jobs time out at AZL_VALIDATE_JOB_TIMEOUT_MINUTES and AZL_DEPLOY_JOB_TIMEOUT_MINUTES (deployment.validate_timeout_minutes, default 90, and deployment.deploy_timeout_minutes, default 360, each plus 60 minutes). Inputs: mode (Plan, Validate, ValidateAndDeploy, Deploy), 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.
Post-Deployment Workflow
File: pipelines/github-actions/post-deployment.yml (copy to .github/workflows/post-deployment.yml). Run it after the ARM deployment succeeded. It runs Invoke-AzureLocalPostDeployment.ps1, the eleven tasks of Phase 06 in one run, and nothing else.
| Job | Description |
|---|---|
validate | Read only. Test-InfrastructureFile.ps1 checks the master file. Always runs |
plan | Read only. -Mode Plan: every selected step with -WhatIf. Always runs after validate; its job summary is what the reviewer reads |
apply | Runs for the input mode Apply, after plan, only after a reviewer of the environment in AZL_ENVIRONMENT_OPERATIONS (devops.pipelines.environments.operations) approves it. -Mode Apply, the same selection. It holds the concurrency group azure-local-day2-changes-<infrastructure file> with the update, the node maintenance and the other changes to the cluster |
approval-environment-not-set | Runs for Apply while AZL_ENVIRONMENT_OPERATIONS is empty, instead of apply: it fails with a message that names the variable, and nothing is changed |
Inputs: mode (Plan or Apply, default Plan), only (steps or tasks, comma-separated, for example task-05 or storage-paths), from and to (a range), continue_on_warning (default off). Empty only, from and to run every step the file turns on. The infrastructure file is the repository variable AZL_INFRASTRUCTURE_FILE, not an input. The artifacts are post-deployment-plan and post-deployment-report: report.json, summary.md, the logs and post-deployment-events.jsonl. The jobs sign in by AZL_AUTH_METHOD and read AZL_AZ_POWERSHELL_VERSION, AZL_AZ_KEYVAULT_VERSION and AZL_POWERSHELL_YAML_VERSION. How to run one task, the SDN gate and the exit codes: Post-Deployment Pipeline.
Validation and Day 2 Workflows
Five workflows run the scripts of Part 7 and Part 8 of the implementation guide, each the command an operator runs by hand and nothing else. Copy each to .github/workflows/ in your repository. How to run each script by hand and in a workflow: Run the Validation in a Pipeline and Run Day 2 Operations in a Pipeline.
| File | Read-only job (no approval) | Approved job | Inputs |
|---|---|---|---|
pipelines/github-actions/validation.yml | validate: the four validation scripts; the storage script without its load test | storage-performance: Test-StoragePerformance.ps1 -RunPerformanceTest, only when asked, after validate passed | run_performance_test (default off) |
pipelines/github-actions/day2-check-updates.yml | check-azure (Azure CLI, no node access) or check-cluster (PowerShell remoting) | none | source (azure or cluster) |
pipelines/github-actions/day2-update.yml | plan: Start-AzureLocalSolutionUpdate.ps1 -WhatIf | apply: PrepareOnly or Install | action (Plan, PrepareOnly, Install), update_mode (AfterDeployment, OnDemand) |
pipelines/github-actions/day2-node-maintenance.yml | plan: the node is checked against nodes[] with -RequireNodeInFile, then -WhatIf | apply: Reboot or Resume (-ResumeOnly) | node (one node), action (Plan, Reboot, Resume) |
pipelines/github-actions/day2-cluster-operations.yml | read-only (HealthCheck, Alerts, Capacity), or plan-changes (-WhatIf) for a change | apply-changes: MaintenanceMode, LiveMigrate or Rebalance | action, node, enable |
- Plan first. The approved job needs the read-only job and starts only when it succeeded. With the action
Plan, the run ends after the plan. - One approval environment. Every approved job runs in the GitHub environment named by the repository variable
AZL_ENVIRONMENT_OPERATIONS(devops.pipelines.environments.operations). Give it required reviewers. - One change at a time. Every approved job has the concurrency group
azure-local-day2-changes-<infrastructure file>withcancel-in-progress: false: a second change waits for the first. GitHub keeps only one waiting run per group, so a third run replaces the waiting second. The read-only jobs hold no lock. - One node per run. The node input is checked against
nodes[]with-RequireNodeInFile. A name the file does not list ends the run with exit code 2 before anything is sent. - A failed script fails the run. The report, plan or log is published as an artifact even then.
Repository variables set by Task 05: AZL_RUNNER_OS, AZL_RUNNER_LABEL, AZL_ENVIRONMENT_OPERATIONS, AZL_INFRASTRUCTURE_FILE, AZL_POWERSHELL_YAML_VERSION. day2-check-updates.yml and day2-node-maintenance.yml also sign in to Azure (ARM_CLIENT_ID, ARM_TENANT_ID, ARM_SUBSCRIPTION_ID, AZL_AUTH_METHOD, and the secret ARM_CLIENT_SECRET with client_secret); the node maintenance also reads AZL_AZ_POWERSHELL_VERSION and AZL_AZ_KEYVAULT_VERSION. The other three workflows do not sign in to Azure.
The account. The scripts connect to the cluster as the service account of the runner, which must be an administrator of the cluster. No workflow passes -Credential or holds a password. The node maintenance reads the node login from its secret reference in infrastructure.yml (identity.local_admin), from Key Vault, with the Azure sign-in of the job. The validation needs the Failover Clustering PowerShell module (RSAT Failover Clustering Tools) on the runner, so a Windows runner. The Azure view of the check for updates needs the Azure CLI on the runner.
The schedule. day2-check-updates.yml runs on on.schedule and by hand. GitHub reads a cron expression only from the workflow file, never from a variable. The sample carries the default of devops.pipelines.schedules.check_for_updates, 17 4 * * * (every day at 04:17 UTC), and a toolkit test keeps the two equal. Task 05 writes the value of your key into the cron line of your copy (.github/workflows/ when the workflow is there); commit it. The same key schedules GitLab and Azure DevOps (D126). A scheduled run has no inputs, so it takes the Azure view. The run fails when the cluster needs attention (exit code 1), so GitHub's notification of a failed run is the alert. The report is the artifact day2-update-check.
While AZL_ENVIRONMENT_OPERATIONS is empty, nothing is changed. A run that would change something fails in the job approval-environment-not-set, with a message that names the variable, and nothing is sent to any machine. The read-only jobs run as before. See No change without an approval environment.
Repository
Source: azurelocal-toolkit/pipelines/github-actions/
Navigation
| Previous | Up | Next |
|---|---|---|
| GitLab CI/CD | Part 2: CI/CD Pipelines | Azure DevOps Pipelines |