@@ -16,49 +16,61 @@ permissions:
1616env :
1717 CURRENT_RELEASE_ENDPOINT : ${{ vars.CURRENT_RELEASE_ENDPOINT }} # Endpoint that returns the current release version in json format
1818jobs :
19- cherry_pick_to_release_branch :
19+ get_release_branch :
2020 if : github.event.pull_request.merged == true &&
2121 contains(github.event.pull_request.labels.*.name, 'To release')
22+ runs-on : ubuntu-latest
23+ outputs :
24+ release_branches : ${{ steps.get_release_version.outputs.release_branches }}
25+ steps :
26+ - name : Get the release version
27+ id : get_release_version
28+ run : |
29+ CURRENT_RELEASE=$(curl -s $CURRENT_RELEASE_ENDPOINT | jq -c '.collate_branches // []')
30+ echo "release_branches=${CURRENT_RELEASE}" >> $GITHUB_OUTPUT
31+
32+ cherry_pick_to_release_branch :
33+ needs : get_release_branch
34+ if : needs.get_release_branch.outputs.release_branches != '' && needs.get_release_branch.outputs.release_branches != '[]'
2235 runs-on : ubuntu-latest # Running it on ubuntu-latest on purpose (we're not using all the free minutes)
36+ strategy :
37+ fail-fast : false
38+ matrix :
39+ branch : ${{ fromJson(needs.get_release_branch.outputs.release_branches) }}
2340 steps :
2441 - name : Checkout main branch
2542 uses : actions/checkout@v4
2643 with :
2744 ref : main
2845 fetch-depth : 0
29- - name : Get the release version
30- id : get_release_version
31- run : |
32- CURRENT_RELEASE=$(curl -s $CURRENT_RELEASE_ENDPOINT | jq -r .om_branch)
33- echo "CURRENT_RELEASE=${CURRENT_RELEASE}" >> $GITHUB_ENV
3446 - name : Cherry-pick changes from PR
3547 id : cherry_pick
3648 continue-on-error : true
3749 run : |
3850 git config --global user.email "release-bot@open-metadata.org"
3951 git config --global user.name "OpenMetadata Release Bot"
40- git fetch origin ${CURRENT_RELEASE }
41- git checkout ${CURRENT_RELEASE }
52+ git fetch origin ${{ matrix.branch } }
53+ git checkout ${{ matrix.branch } }
4254 git cherry-pick -x ${{ github.event.pull_request.merge_commit_sha }}
4355 - name : Push changes to release branch
4456 id : push_changes
4557 continue-on-error : true
4658 if : steps.cherry_pick.outcome == 'success'
4759 run : |
48- git push origin ${CURRENT_RELEASE }
60+ git push origin ${{ matrix.branch } }
4961 - name : Post a comment on failure
5062 if : steps.cherry_pick.outcome != 'success' || steps.push_changes.outcome != 'success'
5163 uses : actions/github-script@v7
5264 with :
5365 script : |
5466 const prNumber = context.payload.pull_request.number;
55- const releaseVersion = process.env.CURRENT_RELEASE ;
67+ const releaseBranch = '${{ matrix.branch }}' ;
5668 const workflowRunUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
5769 github.rest.issues.createComment({
5870 owner: context.repo.owner,
5971 repo: context.repo.repo,
6072 issue_number: prNumber,
61- body: `Failed to cherry-pick changes to the ${releaseVersion } branch.
73+ body: `Failed to cherry-pick changes to the ${releaseBranch } branch.
6274 Please cherry-pick the changes manually.
6375 You can find more details [here](${workflowRunUrl}).`
6476 })
@@ -68,10 +80,10 @@ jobs:
6880 with :
6981 script : |
7082 const prNumber = context.payload.pull_request.number;
71- const releaseVersion = process.env.CURRENT_RELEASE ;
83+ const releaseBranch = '${{ matrix.branch }}' ;
7284 github.rest.issues.createComment({
7385 owner: context.repo.owner,
7486 repo: context.repo.repo,
7587 issue_number: prNumber,
76- body: `Changes have been cherry-picked to the ${releaseVersion } branch.`
88+ body: `Changes have been cherry-picked to the ${releaseBranch } branch.`
7789 })
0 commit comments