11name : Sync Chromium branches
22on :
33 workflow_dispatch :
4- # Runs everyday at midnight UTC .
4+ # Runs everyday.
55 schedule :
66 - cron : ' 0 0 * * *'
7- permissions : read-all
87jobs :
98 sync :
109 runs-on : [self-hosted, chrobalt-linux-runner]
@@ -13,26 +12,46 @@ jobs:
1312 strategy :
1413 fail-fast : false
1514 matrix :
16- # Found here: https://chromiumdash.appspot.com/branches
1715 branch : [
18- {milestone: m114, branch_num: 5735},
19- {milestone: m120, branch_num: 6099},
16+ {milestone: m114, branch_num: 5735},
17+ {milestone: m120, branch_num: 6099},
2018 {milestone: m126, branch_num: 6478},
19+ {milestone: m131, branch_num: 6778},
2120 ]
21+ outputs :
22+ output1 : ${{ steps.diff_step.outputs.diff_present }}
2223 steps :
24+ # Attempt to checkout our chromium reference, if missing we will create a new branch
2325 - uses : actions/checkout@v4
26+ id : checkout
27+ continue-on-error : true
2428 with :
2529 ref : chromium/${{ matrix.branch.milestone }}
30+ - name : Fallback to main branch
31+ uses : actions/checkout@v4
32+ if : steps.checkout.outcome == 'failure'
33+ with :
34+ ref : main
2635 - name : Setup Git
2736 run : |
2837 git config --global user.name "GitHub Release Automation"
2938 git config --global user.email "github@google.com"
30- - name : Pull ${{ matrix.branch.milestone }} from upstream and apply diffs
31- id : diff_step
32- run : |
3339 # Add Chromium remote and pull the upstream branch.
3440 git remote add upstream https://chromium.googlesource.com/chromium/src
3541 git fetch --depth=1 upstream refs/branch-heads/${{ matrix.branch.branch_num }}:refs/remotes/branch/${{ matrix.branch.branch_num }}
42+ - name : Create new branch if missing chromium branch
43+ if : steps.checkout.outcome == 'failure'
44+ run : |
45+ git checkout refs/remotes/branch/${{ matrix.branch.branch_num }}
46+ ORIGINAL_TREE_HASH=$(git rev-parse HEAD^{tree})
47+ ORIGINAL_COMMIT_HASH=$(git rev-parse HEAD)
48+ NEW_ROOT_COMMIT_HASH=$(git commit-tree "$ORIGINAL_TREE_HASH" -m "First commit for ${{ matrix.branch.milestone }}.")
49+ git checkout -b chromium/${{ matrix.branch.milestone }} $NEW_ROOT_COMMIT_HASH
50+ git commit --amend --not-edit -c ORIGINAL_COMMIT_HASH
51+ git push --set-upstream origin chromium/${{ matrix.branch.milestone }}
52+ - name : Pull ${{ matrix.branch.milestone }} from upstream and apply diffs
53+ id : diff_step
54+ run : |
3655 git diff HEAD branch/${{ matrix.branch.branch_num }} --binary > chromium_diff.patch
3756 - name : Apply and push diffs
3857 run : |
0 commit comments