1+ trigger :
2+ - main
3+
4+ variables :
5+ - group : ' DotNet-VSTS-Infra-Access'
6+
7+ resources :
8+ repositories :
9+ - repository : 1esPipelines
10+ type : git
11+ name : 1ESPipelineTemplates/1ESPipelineTemplates
12+ ref : refs/tags/release
13+
14+ extends :
15+ template : v1/1ES.Official.PipelineTemplate.yml@1esPipelines
16+ parameters :
17+ sdl :
18+ codeql :
19+ compiled :
20+ enabled : false
21+ justificationForDisabling : ' This is a mirror pipeline that does not build any code.'
22+ pool :
23+ name : AzurePipelines-EO
24+ image : 1ESPT-Windows2022
25+ os : windows
26+
27+ stages :
28+ - stage : Mirror
29+ jobs :
30+ - job : Mirror
31+ steps :
32+ - task : PowerShell@1
33+ displayName : ' Set SourceBranch Variable'
34+ inputs :
35+ scriptType : inlineScript
36+ arguments : ' $(Build.SourceBranch)'
37+ inlineScript : |
38+ param(
39+ [string]$SourceBranch
40+ )
41+ if ($SourceBranch.StartsWith("refs/heads/"))
42+ {
43+ # strip off the refs/heads/ prefix
44+ $SourceBranch=$SourceBranch.Substring(11)
45+ }
46+ $env:SourceBranch=$SourceBranch
47+ Write-Host ("##vso[task.setvariable variable=SourceBranch;]$env:SourceBranch")
48+
49+ - task : PowerShell@1
50+ displayName : ' Set MirrorBranch Variable'
51+ inputs :
52+ scriptType : inlineScript
53+ inlineScript : |
54+ $env:MirrorBranch='mirror/'+[Guid]::NewGuid().ToString()
55+ Write-Host ("##vso[task.setvariable variable=MirrorBranch;]$env:MirrorBranch")
56+
57+ - task : PipAuthenticate@1
58+ displayName : ' Pip Authenticate'
59+ inputs :
60+ artifactFeeds : ' DevDiv/PerfView-Mirror'
61+
62+ - task : UsePythonVersion@0
63+ displayName : ' Use Python 3.11.x'
64+ inputs :
65+ versionSpec : 3.11.x
66+
67+ - task : CmdLine@1
68+ displayName : ' Update pip to latest'
69+ inputs :
70+ filename : python
71+ arguments : ' -m pip install --upgrade pip'
72+
73+ - task : CmdLine@1
74+ displayName : ' Install Azure CLI'
75+ inputs :
76+ filename : pip
77+ arguments : ' install --pre azure-cli'
78+
79+ - task : CmdLine@1
80+ displayName : ' Install Azure DevOps Extension'
81+ inputs :
82+ filename : az
83+ arguments : ' extension add -n azure-devops'
84+
85+ - task : CmdLine@1
86+ displayName : ' Configure Git user.email'
87+ inputs :
88+ filename : git
89+ arguments :
' config user.email "[email protected] "' 90+
91+ - task : CmdLine@1
92+ displayName : ' Configure git user.name'
93+ inputs :
94+ filename : git
95+ arguments : ' config user.name "dotnet-bot"'
96+
97+ - task : CmdLine@1
98+ displayName : ' Checkout GitHub main Branch'
99+ inputs :
100+ filename : git
101+ arguments : ' checkout $(SourceBranch)'
102+
103+ - task : CmdLine@1
104+ displayName : ' Create Mirror Branch'
105+ inputs :
106+ filename : git
107+ arguments : ' checkout -b $(MirrorBranch)'
108+
109+ - task : CmdLine@1
110+ displayName : ' Run git reset'
111+ inputs :
112+ filename : git
113+ arguments : ' reset --hard origin/$(SourceBranch)'
114+ enabled : false
115+
116+ - task : CmdLine@1
117+ displayName : ' Pull AzDO SourceBranch'
118+ inputs :
119+ filename : ' git '
120+ arguments : ' pull --strategy=recursive --strategy-option no-renames https://dn-bot:$(dn-bot-devdiv-build-rw-code-rw)@devdiv.visualstudio.com/DevDiv/_git/perfView $(SourceBranch)'
121+
122+ - task : CmdLine@1
123+ displayName : ' Run git push '
124+ inputs :
125+ filename : ' git '
126+ arguments : ' push https://dn-bot:$(dn-bot-devdiv-build-rw-code-rw)@devdiv.visualstudio.com/DevDiv/_git/perfView $(MirrorBranch)'
127+
128+ - task : PowerShell@1
129+ displayName : ' Create Pull Request'
130+ inputs :
131+ scriptType : inlineScript
132+ arguments : ' $(dn-bot-devdiv-build-rw-code-rw)'
133+ inlineScript : |
134+ param(
135+ [string]$AccessToken
136+ )
137+ $env:AZURE_DEVOPS_EXT_PAT=$AccessToken
138+ $Organization="https://devdiv.visualstudio.com"
139+ $Project="DevDiv"
140+ $Repository="PerfView"
141+ az devops configure --defaults organization=$Organization project=$Project
142+ az repos pr create --repository $Repository --auto-complete true --delete-source-branch true --title "Mirror Changes from GitHub" --source-branch $(MirrorBranch) --target-branch $(SourceBranch)
0 commit comments