From 6d5330bef40ed55b87cc49cec0cf75eb0a8d5d8c Mon Sep 17 00:00:00 2001 From: Manoramsharma Date: Sat, 27 Jul 2024 13:06:09 +0530 Subject: [PATCH 1/2] Cherry-picker workflow configuration Signed-off-by: Manoramsharma --- .github/workflows/cherry-picker.yml | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/cherry-picker.yml diff --git a/.github/workflows/cherry-picker.yml b/.github/workflows/cherry-picker.yml new file mode 100644 index 00000000000..a82f0a39557 --- /dev/null +++ b/.github/workflows/cherry-picker.yml @@ -0,0 +1,37 @@ +name: Cherry pick + +on: + pull_request: + branches: + - main + types: ["closed"] + +permissions: + contents: read + pull-requests: write + +jobs: + cherry_pick_release_v1_1: + runs-on: ubuntu-22.04 + name: Cherry pick into release/v1.1 + if: ${{ contains(github.event.pull_request.labels.*.name, 'cherrypick/release-v1.1') && github.event.pull_request.merged == true }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + - name: Cherry pick into release/v1.1 + run: | + TARGET_BRANCH="release/v1.1" + MERGE_COMMIT_SHA=$(git log -1 --pretty=format:%H) + + git fetch origin $TARGET_BRANCH + git checkout $TARGET_BRANCH + git cherry-pick $MERGE_COMMIT_SHA || git cherry-pick --abort + git push origin $TARGET_BRANCH From 07acb97cd57a21a972314f9db6d81bbef8df8494 Mon Sep 17 00:00:00 2001 From: Manoramsharma Date: Sat, 27 Jul 2024 16:23:41 +0530 Subject: [PATCH 2/2] Resmoved direct push to target made separate branch Signed-off-by: Manoramsharma --- .github/workflows/cherry-picker.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cherry-picker.yml b/.github/workflows/cherry-picker.yml index a82f0a39557..67e35ed4ba3 100644 --- a/.github/workflows/cherry-picker.yml +++ b/.github/workflows/cherry-picker.yml @@ -29,9 +29,25 @@ jobs: - name: Cherry pick into release/v1.1 run: | TARGET_BRANCH="release/v1.1" + CHERRY_PICK_BRANCH="cherry-pick-$(date +'%Y%m%d%H%M%S')" MERGE_COMMIT_SHA=$(git log -1 --pretty=format:%H) + # Fetch and create new branch from target git fetch origin $TARGET_BRANCH - git checkout $TARGET_BRANCH + git checkout -b $CHERRY_PICK_BRANCH origin/$TARGET_BRANCH + + # Cherry-pick the commit git cherry-pick $MERGE_COMMIT_SHA || git cherry-pick --abort - git push origin $TARGET_BRANCH + + # Push the new branch + git push origin $CHERRY_PICK_BRANCH + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Cherry pick ${MERGE_COMMIT_SHA} into ${TARGET_BRANCH}" + branch: $CHERRY_PICK_BRANCH + title: "[release/v1.1] Cherry pick ${MERGE_COMMIT_SHA}" + body: "Cherry picking commit ${MERGE_COMMIT_SHA} onto ${TARGET_BRANCH}" + base: $TARGET_BRANCH