Skip to content

Cleanup changesets 3.20.16 #592

Cleanup changesets 3.20.16

Cleanup changesets 3.20.16 #592

Workflow file for this run

name: Auto cherry pick
on:
pull_request:
branches:
- main
types: ["closed", "labeled"]
jobs:
cherry_pick:
runs-on: ubuntu-22.04
name: Cherry pick into release branch
if: ${{ github.event.pull_request.merged == true }}
permissions:
contents: write
pull-requests: write
steps:
- name: Obtain release
env:
PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
labels="$PR_LABELS"
release_label=$(jq -r '.[] | select(contains("release:"))' <<< $labels)
version=$(sed "s/release://g" <<< $release_label)
echo "TARGET_VERSION=$version" >> $GITHUB_ENV
- name: Checkout
if: env.TARGET_VERSION != ''
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cherry pick into ${{ env.TARGET_VERSION }}
if: env.TARGET_VERSION != ''
env:
GH_TOKEN: ${{ github.token }}
PR_BRANCH: pick-${{ github.event.pull_request.head.ref }}-${{ env.TARGET_VERSION }}
ORIGIN_BRANCH: origin/${{ env.TARGET_VERSION }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
PULL_REQUEST_AUTHOR: ${{ github.event.pull_request.user.login }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote update
git fetch --all
git checkout -b "$PR_BRANCH" "$ORIGIN_BRANCH"
git cherry-pick \
-m 1 \
--strategy=recursive \
--strategy-option=theirs \
"$GITHUB_SHA"
git push -u origin "$PR_BRANCH"
gh pr create \
--title "$PULL_REQUEST_TITLE" \
--body "Pick: #$PULL_REQUEST_NUMBER" \
--base "$TARGET_VERSION" \
--head "$PR_BRANCH" \
--label "cherry-pick" \
--assignee "$PULL_REQUEST_AUTHOR"