Skip to main content

Task 03: Configure Project Settings

Runbook GitHub GitLab Azure DevOps

DOCUMENT CATEGORY: Runbook Step
SCOPE: Source control project configuration
PURPOSE: Configure repository settings, branch protection, and merge/pull request approvals MASTER REFERENCE: Azure DevOps Project Settings

Status: Active


Objective​

Configure required settings for the source control project. Most settings are replicated from the template, but must be verified. Select your platform below for platform-specific instructions.


Prerequisites​

  • Source control project created (Task 02)
  • Admin / Maintainer role in the project

Procedure​

Branch Protection​

Protect the main branch to prevent direct pushes and require reviews before merging.

  1. Navigate to Settings → Branches
  2. Click Add branch protection rule
  3. Set Branch name pattern to main
  4. Enable the following:
SettingValue
Require a pull request before merging✅
Require approvals✅ (see Approval Rules below)
Dismiss stale pull request approvals when new commits are pushed✅
Require status checks to pass before merging✅
Require conversation resolution before merging✅
Do not allow bypassing the above settings✅
Restrict who can push to matching branches✅ (No direct pushes)
Allow force pushes❌ Disabled
Allow deletions❌ Disabled
  1. Click Save changes

References: GitHub — Branch protection rules

Push Rules / Security Settings​

GitHub handles push security via branch protection (configured above) and repository settings:

  1. Navigate to Settings → Code security and analysis
  2. Enable:
    • ✅ Secret scanning — detect committed secrets
    • ✅ Push protection — block pushes containing secrets
  3. Navigate to Settings → General → Pull Requests
    • ✅ Allow squash merging (set default commit message)
    • ❌ Disable merge commits and rebase merging (optional — enforce squash)

Merge / Pull Request Approvals​

Configure required approvals in Settings → Branches → branch protection rule for main:

Project TypeRequired ApprovalsReviewers
Sandbox/Lab0—
Core repos3@AzureLocal/cicd team
Deployment repos2@AzureLocal/pcie team
All others2@AzureLocal/cicd team

Optionally, add a CODEOWNERS file to the repository root to auto-assign reviewers:

CODEOWNERS
# Default reviewers for all files
* @AzureLocal/cicd

References: GitHub — CODEOWNERS


Verification​

  • main branch protected — no direct pushes allowed
  • Push rules / security scanning configured
  • Merge/PR approval rules added with correct reviewer counts
  • Squash merge enforced (or preferred merge strategy set)

Next Steps​

Create Environments


References​


Values from infrastructure.yml​

The script reads devops.settings (required approvals, reviewers, squash only, secret scanning, resolve conversations, required status checks) of infrastructure.yml (schema 5). Each key, with its type, default and example, is in the variables reference.


Toolkit script

The toolkit script for this task is PowerShell 7. It reads infrastructure.yml through the mandatory -InfrastructureFile parameter and never prompts. It ends with exit code 0, 1 or 2. Run it with -WhatIf first: the script reads what exists and lists what it would do.

Script​

ScriptWhat it does
scripts/deploy/01-cicd-infra/phase-01-cicd-setup/task-03-configure-project/powershell/Set-CicdProjectConfiguration.ps1Task 03. Sets branch protection, approvals, merge rules and security on the project. Supports -WhatIf.

Requires: PowerShell 7.

Run​

./Set-CicdProjectConfiguration.ps1 -InfrastructureFile ./infrastructure.yml -WhatIf

Alternatives​

The procedures in this task use the methods shown in the tabs above. The toolkit is PowerShell 7 only and has no Bash scripts. A few tasks that act on Azure also have an Azure CLI script written in PowerShell. The script status page of the toolkit lists which task has which script.

PreviousUpNext
← Task 02: Create source control projectPhase 01: CI/CD SetupTask 04: Create Environments ->

Troubleshooting​

IssueCauseResolution
Branch policies not applyingInsufficient project admin permissionsVerify user has Project Administrator role
Pipeline configuration failsInvalid YAML syntax in pipeline definitionValidate YAML syntax using pipeline editor

Version Control​

VersionDateAuthorChanges
1.0.02025-03-25Azure Local CloudInitial release