Skip to content

Commit

Permalink
Enable Release Branches for Automated CI (microsoft#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Mar 9, 2020
1 parent 0c09ad5 commit 31dbe6c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
7 changes: 7 additions & 0 deletions .azure/azure-pipelines-int.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
#

trigger:
batch: true
branches:
include:
- master
- release/*
pr:
- master
- release/*

name: 0.$(Date:yyMM).$(DayOfMonth)$(Rev:rr).0

Expand Down
7 changes: 6 additions & 1 deletion .azure/azure-pipelines.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
#

trigger:
- master
batch: true
branches:
include:
- master
- release/*
pr:
- master
- release/*

name: 0.$(Date:yyMM).$(DayOfMonth)$(Rev:rr).0

Expand Down
14 changes: 9 additions & 5 deletions .azure/scripts/sync-mirror.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,38 @@ This synchronizes a branch on the current repository to the mirror repo.
sync-mirror.ps1
.EXAMPLE
sync-mirror.ps1 -Branch release/xxxx
sync-mirror.ps1 -Branch refs/heads/release/xxxx
#>

param (
[Parameter(Mandatory = $false)]
[string]$Branch = "master"
[string]$Branch = "refs/heads/master"
)

Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'

# Verify the PAT environmental variable is set.
if ($null -eq $Env:AzDO_PAT -or "" -eq $Env:AzDO_PAT) {
Write-Error "PAT for Azure DevOps Repo doesn't exist!"
}

# Remove the 'refs/heads/' prefix.
$BranchName = $Branch.Substring(11)

# Make sure we're in the correct branch.
git checkout $Branch
git checkout $BranchName

# Add the AzDO repo as a remote.
git remote add azdo-mirror "https://nibanks:$Env:AzDO_PAT@mscodehub.visualstudio.com/msquic/_git/msquic"

# Reset branch to origin.
git reset --hard origin/$Branch
git reset --hard origin/$BranchName

# Push to the AzDO repo.
try {
git push azdo-mirror $Branch
git push azdo-mirror $BranchName
} catch {
Write-Host "Supressing exception while running 'git push'"
}
Expand Down
9 changes: 3 additions & 6 deletions .azure/templates/sync-mirror.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# This template contains steps to sync the GitHub repo to the AzDO mirror repo.

parameters:
branch: 'master'

jobs:
- job: mirror_${{ parameters.branch }}
displayName: Mirror ${{ parameters.branch }} branch
- job: mirror
displayName: Mirror branch
pool:
vmImage: windows-latest
steps:
Expand All @@ -17,6 +14,6 @@ jobs:
inputs:
pwsh: true
filePath: .azure/scripts/sync-mirror.ps1
arguments: -Branch ${{ parameters.branch }}
arguments: -Branch $(Build.SourceBranch)
env:
AzDO_PAT: $(AzDO_PAT)

0 comments on commit 31dbe6c

Please sign in to comment.