File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
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
+
You can’t perform that action at this time.
0 commit comments