Skip to content

Commit 9e89b5c

Browse files
authored
Create pipeline to sync mirror repo (#1286)
1 parent 629f9e7 commit 9e89b5c

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.pipelines/sync-mirror.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Sync branches in a mirror repository to a base repo by running this pipeline
2+
# from the mirror repo, and supplying the base repo as a parameter
3+
name: $(BuildDefinitionName)_$(date:yyMMdd)$(rev:.r)
4+
5+
parameters:
6+
- name: "SourceToTargetBranches"
7+
type: object
8+
default:
9+
master: master
10+
- name: "SourceRepository"
11+
type: string
12+
default: "https://github.com/microsoft/cppwinrt.git"
13+
14+
jobs:
15+
- job: SyncMirror
16+
strategy:
17+
matrix:
18+
${{ each branches in parameters.SourceToTargetBranches }}:
19+
${{ branches.key }}:
20+
SourceBranch: ${{ branches.key }}
21+
TargetBranch: ${{ branches.value }}
22+
dependsOn: []
23+
pool:
24+
name: Azure Pipelines
25+
vmImage: 'windows-2022'
26+
steps:
27+
- checkout: self
28+
persistCredentials: true
29+
30+
- task: PowerShell@2
31+
inputs:
32+
targetType: 'inline'
33+
script: |
34+
Write-Host "SourceBranch " + "$(SourceBranch)"
35+
Write-Host "TargetBranch " + "$(TargetBranch)"
36+
37+
$repo = "${{ parameters.SourceRepository }}"
38+
git remote add sourcerepo $repo
39+
git remote
40+
41+
$target = "$(TargetBranch)"
42+
git fetch origin $target
43+
git checkout $target
44+
git pull origin $target
45+
46+
$source = "$(SourceBranch)"
47+
git fetch sourcerepo $source
48+
git pull sourcerepo $source
49+
50+
- task: CmdLine@2
51+
inputs:
52+
script: |
53+
git push
54+

0 commit comments

Comments
 (0)