-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-merge-mirror.yml
59 lines (56 loc) · 2.6 KB
/
azure-pipelines-merge-mirror.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Disable CI triggers, only called using Maestro
trigger: none
# Merges code from GitHub into internal branches in internal repos
jobs:
- template: /eng/common/templates/jobs/jobs.yml
parameters:
enableTelemetry: true
helixRepo: dotnet/arcade
jobs:
- job: Merge_GitHub_to_Azure_DevOps
pool:
name: Hosted VS2017
variables:
- name: WorkingDirectoryName
value: repo-dir
steps:
- task: PowerShell@1
displayName: Calculate Merge Branch Names
inputs:
scriptType: inlineScript
arguments: '$(GithubRepo) $(BranchToMirror)'
inlineScript: |
param([string]$repo, [string]$branch)
$azDORepo = $repo.Replace("/", "-");
# Check that the parameters look correct
if ($azDORepo -eq "" -or $branch -eq "")
{
Write-Error "Expected valid branch and GitHub repo in the form of owner/repo"
}
$targetBranch = "internal/$branch"
Write-Host "##vso[task.setvariable variable=AzDORepoNameName]$azDORepo"
Write-Host "##vso[task.setvariable variable=TargetBranchName]$targetBranch"
Write-Host "Merging branch '$branch' in GitHub repo '$repo' to $targetBranch in Azure DevOps repo '$azDORepo'."
- script: |
git clone https://dotnet-maestro-bot:$(BotAccount-dotnet-maestro-bot-PAT)@github.com/$(GithubRepo) $(WorkingDirectoryName) -b $(BranchToMirror)
displayName: Clone GitHub repo
- script: |
git remote add azdo-mirror https://dn-bot:$(dn-bot-dnceng-build-rw-code-rw)@dev.azure.com/dnceng/internal/_git/$(AzDORepoNameName)
displayName: Add Azure DevOps remote
workingDirectory: $(WorkingDirectoryName)
- script: |
git fetch azdo-mirror
displayName: Fetch AzDO repo
workingDirectory: $(WorkingDirectoryName)
- script: |
git checkout -b $(TargetBranchName) -t azdo-mirror/$(TargetBranchName) || git checkout -b $(TargetBranchName) -t azdo-mirror/$(BranchToMirror)
displayName: Check out target branch
workingDirectory: $(WorkingDirectoryName)
- script: |
git -c user.email="[email protected]" -c user.name="dotnet-bot" merge origin/$(BranchToMirror) -m "Merge in '$(BranchToMirror)' changes"
displayName: Merge open to target branch
workingDirectory: $(WorkingDirectoryName)
- script: |
git push azdo-mirror $(TargetBranchName) $(ExtraPushArgs)
displayName: Push changes to Azure DevOps repo
workingDirectory: $(WorkingDirectoryName)