Skip to content

Commit d0cc480

Browse files
de-nordiccarlescufi
authored andcommitted
script: Auto-upmerging sdk-mcuboot from upstream
The commit adds auto-upmerging workflow for sdk-mcuboot. Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent 36b2a56 commit d0cc480

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

.github/workflows/create-upmerge-PRs.yml

+26-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on: workflow_dispatch
88
env:
99
GH_TOKEN: ${{ secrets.NCS_GITHUB_UPMERGE_TOKEN }}
1010
ZEPHYR_UPSTREAM: https://github.com/zephyrproject-rtos/zephyr
11+
MCUBOOT_UPSTREAM: https://github.com/zephyrproject-rtos/mcuboot
1112
PR_TARGET_BRANCH: upmerge-tmp
1213

1314
jobs:
@@ -31,15 +32,18 @@ jobs:
3132
working-directory: ncs
3233
run: |
3334
west init -l nrf
34-
west update zephyr bsim
35+
west update zephyr bsim mcuboot
3536
git config --global user.email "noreply@nordicsemi.no"
3637
git config --global user.name "Nordic Builder"
3738
echo "SDK_ZEPHYR=$(west list zephyr -f {url} | awk -F// '{print $NF}')" >> $GITHUB_ENV
39+
echo "SDK_MCUBOOT=$(west list mcuboot -f {url} | awk -F// '{print $NF}')" >> $GITHUB_ENV
3840
3941
- name: Try closing existing auto-upmerge PRs
4042
run: |
4143
SDK_ZEPHYR_PR=$(gh pr list --repo $SDK_ZEPHYR --label "auto-upmerge" --json number --jq .[0].number)
4244
gh pr close $SDK_ZEPHYR_PR --repo $SDK_ZEPHYR | true
45+
SDK_MCUBOOT_PR=$(gh pr list --repo $SDK_MCUBOOT --label "auto-upmerge" --json number --jq .[0].number)
46+
gh pr close $SDK_MCUBOOT_PR --repo $SDK_MCUBOOT | true
4347
SDK_NRF_PR=$(gh pr list --repo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY --label "auto-upmerge" --json number --jq .[0].number)
4448
gh pr close $SDK_NRF_PR --repo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY | true
4549
@@ -50,22 +54,42 @@ jobs:
5054
git checkout -b upmerge_local
5155
west ncs-upmerger zephyr
5256
git push origin upmerge_local:auto-upmerge/$GITHUB_RUN_ID -u
57+
MCUBOOT_UPSTREAM_REV=$(cat west.yml | awk -e '/- name: mcuboot/,/path: bootloader\/mcuboot/ { if ($0 ~ "revision:.*") { print $2; }; }')
5358
5459
UPSTREAMHASH=$(git rev-parse --short upstream/main)
5560
ZEPHYR_PR_URL=$(gh pr create --base $PR_TARGET_BRANCH --title "[nrf mergeup] Merge upstream automatically up to commit $UPSTREAMHASH" --body "Automatic upmerge action" --repo $SDK_ZEPHYR --label "auto-upmerge")
5661
echo "ZEPHYR_PR_URL=$ZEPHYR_PR_URL" >> $GITHUB_ENV
5762
echo "Created PR: $ZEPHYR_PR_URL"
63+
echo "MCUboot revision used by upstream: ${MCUBOOT_UPSTREAM_REV}"
64+
echo "MCUBOOT_UPSTREAM_REV=${MCUBOOT_UPSTREAM_REV}" >> $GITHUB_ENV
65+
66+
- name: Run ncs-upmerge and create sdk-mcuboot upmerge PR
67+
working-directory: ncs/bootloader/mcuboot
68+
run: |
69+
git remote add -f upstream $MCUBOOT_UPSTREAM && git remote add -f origin https://nordicbuilder:${{secrets.NCS_GITHUB_UPMERGE_TOKEN}}@$SDK_MCUBOOT
70+
git checkout -b upmerge_local
71+
west ncs-upmerger mcuboot
72+
git push origin upmerge_local:auto-upmerge/$GITHUB_RUN_ID -u
73+
74+
UPSTREAMHASH=${MCUBOOT_UPSTREAM_REV}
75+
MCUBOOT_PR_URL=$(gh pr create --base $PR_TARGET_BRANCH --title "[nrf mergeup] Merge upstream automatically up to commit $UPSTREAMHASH" --body "Automatic upmerge action" --repo $SDK_MCUBOOT --label "auto-upmerge")
76+
echo "MCUBOOT_PR_URL=$MCUBOOT_PR_URL" >> $GITHUB_ENV
77+
echo "Created PR: $MCUBOOT_PR_URL"
78+
5879
5980
- name: create sdk-nrf PR with updated west.yml
6081
working-directory: ncs/nrf
6182
run: |
6283
NEW_REV=$(echo "pull/$(basename $ZEPHYR_PR_URL)/head" | sed 's/\//\\\//g')
84+
NEW_MCUBOOT_REV=$(echo "pull/$(basename $MCUBOOT_PR_URL)/head" | sed 's/\//\\\//g')
6385
OLD_REV=$(west list zephyr -f {revision})
86+
OLD_MCUBOOT_REV=$(west list mcuboot -f {revision})
6487
git checkout -b upmerge_local
6588
sed -i "s/revision: $OLD_REV/revision: $NEW_REV/" west.yml
89+
sed -i "s/revision: $OLD_MCUBOOT_REV/revision: $NEW_MCUBOOT_REV/" west.yml
6690
git commit -a -m "manifest: Update sdk-zephyr revision (automatic Zephyr upmerge)" -m "Automatically created by Github Action" --signoff
6791
git push origin upmerge_local:auto-upmerge/$GITHUB_RUN_ID -u
68-
gh pr create --base $PR_TARGET_BRANCH --title "manifest: Update sdk-zephyr revision (automatic upmerge)" --body "Automatic upmerge action" --label "CI-all-test" --label "auto-upmerge"
92+
gh pr create --base $PR_TARGET_BRANCH --title "manifest: Update revisions of upmerged projects (automatic upmerge)" --body "Automatic upmerge action" --label "CI-all-test" --label "auto-upmerge"
6993
7094
failure-notifier:
7195
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)