forked from dotnet/arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vsts-code-mirror.yml
45 lines (43 loc) · 1.78 KB
/
.vsts-code-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
# Disable CI triggers, only called using Maestro
trigger: none
# Moves code from GitHub into internal repos
phases:
- template: /eng/common/templates/phases/base.yml
parameters:
agentsOS: Windows_NT
name: Mirror_GitHub_to_VSTS
queue:
name: Hosted VS2017
variables:
WorkingDirectoryName: repo-dir
steps:
- task: PowerShell@1
displayName: Calculate Mirrored Branch Names
inputs:
scriptType: inlineScript
arguments: '$(GithubRepo) $(BranchToMirror)'
inlineScript: |
param([string]$repo, [string]$branch)
$vstsRepo = $repo.Replace("/", "-");
# Check that the parameters look correct
if ($vstsRepo -eq "" -or $branch -eq "")
{
Write-Error "Expected valid branch and GitHub repo in the form of owner/repo"
}
Write-Host "##vso[task.setvariable variable=VstsRepoName]$vstsRepo"
Write-Host "Mirroring branch '$branch' from GitHub repo '$repo' to VSTS repo '$vstsRepo'."
- 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 vsts-mirror https://dn-bot:$(dn-bot-dnceng-build-rw-code-rw)@dev.azure.com/dnceng/internal/_git/$(VstsRepoName)
displayName: Add VSTS remote
workingDirectory: $(WorkingDirectoryName)
- script: |
git reset --hard origin/$(BranchToMirror)
displayName: Hard reset local branch to GitHub branch
workingDirectory: $(WorkingDirectoryName)
- script: |
git push vsts-mirror $(BranchToMirror) $(ExtraPushArgs)
displayName: Push changes to VSTS repo
workingDirectory: $(WorkingDirectoryName)