Skip to content

Commit f270d73

Browse files
authored
add github action to sync main to future (#25562)
1 parent 53c2c9a commit f270d73

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: sync-main
2+
run-name: Sync commit from main to future - temporary
3+
env:
4+
GH_TOKEN: ${{ github.token }}
5+
on:
6+
push:
7+
branches:
8+
- 'main'
9+
jobs:
10+
sync_generation:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
ref: 'future'
18+
- name: sync main
19+
shell: pwsh
20+
run: |
21+
$commitMessage = '${{ github.event.head_commit.message }}'
22+
$commitMessagePatternToIgnore = @()
23+
$commitMessagePatternToIgnore += "^Migrate\s\w+\sfrom\sgeneration\sto\smain"
24+
$commitMessagePatternToIgnore += "^Move\s\w+\sto\smain"
25+
foreach ($pattern in $commitMessagePatternToIgnore) {
26+
if ($commitMessage -match $ignoreCommitPattern) {
27+
Write-Host -ForegroundColor DarkGreen "Commit: [$commitMessage], is for gen2main, skip this run ..."
28+
return
29+
}
30+
}
31+
$commitId = '${{ github.event.head_commit.id }}'
32+
$commitIdShort = $commitId.Subsctring(0,5)
33+
34+
git config user.email "[email protected]";
35+
git config user.name "azure-powershell-bot";
36+
37+
$branchName = "eng/sync-main-to-future-$commitIdShort"
38+
git checkout -b $branchName
39+
40+
$prInfo = "Sync commit [$commitMessage ($commitId)] from main branch to future branch .."
41+
Write-Host -ForegroundColor DarkGreen $prInfo
42+
43+
git fetch origin main
44+
git cherry-pick $commitId --strategy-option theirs
45+
git push origin head
46+
gh pr create -B $branchName -H future --title $commitMessage --body $prInfo

0 commit comments

Comments
 (0)