forked from dotnet/runtimelab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime-master-mirror.yml
72 lines (63 loc) · 2.5 KB
/
runtime-master-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
60
61
62
63
64
65
66
67
68
69
70
71
72
# Disable triggers as it should only be called using Maestro
trigger: none
jobs:
- job: Mirror_runtime_to_runtimelab
displayName: Mirror runtime to runtimelab
pool:
vmImage: 'windows-2019'
variables:
- name: WorkingDirectoryName
value: repo-dir
- name: SourceRemote
value: runtime
- name: SourceBranch
value: master
- name: TargetBranch
value: runtime-master
- group: DotNet-Maestro
steps:
- checkout: none
- script: git clone https://runtimelab-bot:$(_runtimelab-bot)@github.com/dotnet/runtimelab $(WorkingDirectoryName) -b $(TargetBranch)
displayName: Clone runtimelab
- script: git remote add $(SourceRemote) https://github.com/dotnet/$(SourceRemote)
displayName: Add source $(SourceRemote)
workingDirectory: $(WorkingDirectoryName)
- script: git fetch $(SourceRemote) $(SourceBranch)
displayName: Git fetch $(SourceRemote)/$(SourceBranch)
workingDirectory: $(WorkingDirectoryName)
- script: git reset --hard $(SourceRemote)/$(SourceBranch)
displayName: Reset branch
workingDirectory: $(WorkingDirectoryName)
- task: PowerShell@2
displayName: Push changes to runtimelab/$(TargetBranch)
inputs:
targetType: inline
workingDirectory: $(WorkingDirectoryName)
script: |
git push origin $(TargetBranch) $(ExtraPushArgs)
if ($LASTEXITCODE -EQ 0) {
Write-Host "Push was successful"
exit
}
git fetch origin
git fetch $(SourceRemote)
$commits = (git --no-pager rev-list $(SourceRemote)/$(SourceBranch)..origin/$(TargetBranch) | Measure-Object -line).Lines
if ($commits -NE 0) {
Write-Host "##vso[task.LogIssue type=error;]Mirror repository runtimelab has unexpected commits"
git --no-pager log $(SourceRemote)/$(SourceBranch)..origin/$(TargetBranch)
exit 1
}
Write-Host "##vso[task.LogIssue type=warning;]Push failed for unknown reason"
$retryattempt=0
while ($retryattempt -LT 3) {
$retryattempt+=1
Write-Host "Retry attempt $retryattempt of 3 in 5 seconds..."
Start-Sleep -Seconds 5
git push origin $(TargetBranch) $(ExtraPushArgs)
if ($LASTEXITCODE -EQ 0) {
Write-Host "Push successful"
exit
}
}
Write-Host "##vso[task.LogIssue type=error;]git failed to push to Azure DevOps mirror"
exit 1