Automatically Sync Master after Successful CI Build (#138)

This commit is contained in:
Nick Banks 2020-02-14 08:58:29 -08:00 коммит произвёл GitHub
Родитель 805fdb7aa2
Коммит 58a76c3e54
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 61 добавлений и 0 удалений

Просмотреть файл

@ -20,10 +20,19 @@ stages:
- template: ./templates/build-windows.yml
- template: ./templates/build-linux.yml
# Mirror
- stage: mirror
displayName: Mirror
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'))
jobs:
- template: ./templates/sync-mirror.yml
# Tests
- stage: test
displayName: Test
dependsOn: build
jobs:
## Build Verification Tests

Просмотреть файл

@ -0,0 +1,32 @@
<#
.SYNOPSIS
This synchronizes a branch on the current repository to the mirror repo.
.EXAMPLE
sync-mirror.ps1
.EXAMPLE
sync-mirror.ps1 -Branch release/xxxx
#>
param (
[Parameter(Mandatory = $false)]
[string]$Branch = "master"
)
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
# Make sure we're in the correct branch.
git checkout $Branch
# 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
# Push to the AzDO repo.
git push azdo-mirror $Branch

Просмотреть файл

@ -0,0 +1,20 @@
# 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
pool:
vmImage: windows-latest
steps:
- checkout: self
persistCredentials: true
- task: PowerShell@2
displayName: Sync Changes to AzDO Mirror Branch
inputs:
pwsh: true
filePath: scripts/sync-mirror.ps1
arguments: -Branch ${{ parameters.branch }}