Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: find a way to reenable the cherry-picker process #3958

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/cherry-picker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Cherry pick

on:
pull_request:
branches:
- main
types: ["closed"]

permissions:
contents: read
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create branch with read permission?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pointing that out. I should have update the permissions in the workflow to ensure that the action can create and push branches. The permissions should be set to contents: write and pull-requests: write.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Manoramsharma thanks for you work, but I think this's not a good issue for begginer(this one need a lot of collaborations with the Envoyproxy org admin).

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"
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 -b $CHERRY_PICK_BRANCH origin/$TARGET_BRANCH

# Cherry-pick the commit
git cherry-pick $MERGE_COMMIT_SHA || git cherry-pick --abort

# 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
Loading