Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .azure-pipelines/templates/Ado.Sync.Mirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Sync branches in a mirror repository to a base repo by running this pipeline
# from the mirror repo, and supplying the base repo as a parameter
name: $(BuildDefinitionName)_$(date:yyMMdd)$(rev:.r)
Comment thread
bbonaby marked this conversation as resolved.

parameters:
- name: "SourceToTargetBranches"
type: object
default:
main: main
- name: "SourceRepository"
type: string
default: "https://github.com/microsoft/mxc.git"

resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-2022
os: windows
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: stage
jobs:
- job: SyncMirror
strategy:
matrix:
${{ each branches in parameters.SourceToTargetBranches }}:
${{ branches.key }}:
Comment thread
bbonaby marked this conversation as resolved.
SourceBranch: ${{ branches.key }}
TargetBranch: ${{ branches.value }}
dependsOn: []
steps:
- checkout: self
persistCredentials: true
Comment thread
bbonaby marked this conversation as resolved.

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "SourceBranch " + "$(SourceBranch)"
Write-Host "TargetBranch " + "$(TargetBranch)"

$repo = "${{ parameters.SourceRepository }}"
git remote add sourcerepo $repo
git remote

$target = "$(TargetBranch)"
git fetch origin $target
git checkout $target
Comment thread
bbonaby marked this conversation as resolved.
git pull origin $target

$source = "$(SourceBranch)"
git fetch sourcerepo $source
git pull sourcerepo $source
Comment thread
bbonaby marked this conversation as resolved.
Comment thread
bbonaby marked this conversation as resolved.

- task: CmdLine@2
inputs:
script: |
git push
Loading