Skip to content

Commit 9ba59f9

Browse files
authored
Add script to mirror one internal branch to another (#41715)
* Add script to mirror one internal branch to another * Fix trigger * params * Fixup * Feedback * Only run on check-ins * Individual -> Batched * No repo * Fix condition
1 parent df123f1 commit 9ba59f9

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configure which branches trigger builds
2+
trigger:
3+
batch: true
4+
branches:
5+
include:
6+
- internal/release/6.0
7+
8+
variables:
9+
- group: Mirror-Credentials
10+
11+
# Merges code from one AzDO branch into another
12+
jobs:
13+
- template: /eng/common/templates/jobs/jobs.yml
14+
parameters:
15+
enableTelemetry: true
16+
helixRepo: dotnet/arcade
17+
jobs:
18+
- job: Merge_Azure_DevOps_Branches
19+
enableSBOM: false
20+
condition: and(contains(variables['Build.SourceBranch'], 'internal'), eq(variables['Build.Reason'], 'BatchedCI'))
21+
pool:
22+
name: NetCore1ESPool-Internal
23+
demands: ImageOverride -equals Build.Server.Amd64.VS2019
24+
variables:
25+
- name: WorkingDirectoryName
26+
value: repo-dir
27+
- name: AzdoRepo
28+
value: dotnet-aspnetcore
29+
- name: TargetBranchName
30+
value: $(Build.SourceBranch)-nonstable
31+
- name: BranchToMirror
32+
value: $(Build.SourceBranch)
33+
steps:
34+
- script: |
35+
git clone https://dn-bot:$(dn-bot-dnceng-build-rw-code-rw)@dev.azure.com/dnceng/internal/_git/$(AzdoRepo) $(WorkingDirectoryName) --recursive --no-tags --branch $(TargetBranchName)
36+
displayName: Clone AzDO repo
37+
- script: |
38+
git -c user.email="[email protected]" -c user.name="dotnet-bot" merge origin/$(BranchToMirror) -m "Merge in '$(BranchToMirror)' changes"
39+
displayName: Merge head branch to target branch
40+
workingDirectory: $(WorkingDirectoryName)
41+
- script: |
42+
git push origin $(TargetBranchName)
43+
displayName: Push changes to Azure DevOps repo
44+
workingDirectory: $(WorkingDirectoryName)
45+
46+
- task: PowerShell@1
47+
displayName: Broadcast target, branch, commit in metadata
48+
continueOnError: true
49+
condition: always()
50+
inputs:
51+
scriptType: inlineScript
52+
arguments: '$(BranchToMirror)'
53+
workingDirectory: $(WorkingDirectoryName)
54+
inlineScript: |
55+
param([string]$branch)
56+
57+
$commit = (git rev-parse HEAD).Substring(0, 7)
58+
$target = "$branch".Replace('/', ' ')
59+
60+
Write-Host "##vso[build.updatebuildnumber]$target $commit"
61+
Write-Host "##vso[build.addbuildtag]$target"

0 commit comments

Comments
 (0)