From 013f934d5516282ad9a03622151ac8475de6e910 Mon Sep 17 00:00:00 2001 From: Jack Green Date: Wed, 27 Nov 2024 14:26:11 +0000 Subject: [PATCH] Add `omit-labels` functionality [DOC-268] (#15) When backports are triggered via PR labels, copying the labels to the backport PRs can cause an unexpected cascade. E.G.: - a PR is labelled to backport to multiple branches - an action performs these actions _in parallel_ - the backported, labelled PRs are detected - more backporting is performed - etc Instead it would be easier to _optionally_ omit copying labels to backported PRs. Fixes: [DOC-268](https://hazelcast.atlassian.net/browse/DOC-268) [DOC-268]: https://hazelcast.atlassian.net/browse/DOC-268?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- .github/actions/backport/action.yml | 6 +++++- backport | 14 +++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/actions/backport/action.yml b/.github/actions/backport/action.yml index 107de84..97f5706 100644 --- a/.github/actions/backport/action.yml +++ b/.github/actions/backport/action.yml @@ -11,6 +11,9 @@ inputs: REF_TO_BACKPORT: description: The reference of the commit to be backported required: true + BACKPORT_OPTIONS: + description: Additional options to pass through to the tool + required: false env: # Not possible to set this as a default @@ -54,7 +57,8 @@ runs: ${GITHUB_ACTION_PATH}/../../../backport \ "${{ inputs.REF_TO_BACKPORT }}" \ "${backport_target_branch}" \ - --non-interactive + --non-interactive \ + ${{ inputs.BACKPORT_OPTIONS }} env: GH_TOKEN: ${{ github.token }} diff --git a/backport b/backport index ff6c989..c36a5fd 100755 --- a/backport +++ b/backport @@ -13,6 +13,7 @@ function usage() { echo " -l, --local Skip pushing the branch and creating the PR" echo " -c, --continue Continue backporting after fixing cherry-pick conflict" echo " -ni, --non-interactive Headlessly creates the PR automatically, without previewing in web browser" + echo " -ol, --omit-labels Omit copying labels to backport PR" echo echo "What does it do:" echo " '$(basename "$0") master upstream/5.2.z' - will perform the following actions:" @@ -57,6 +58,10 @@ get_opts() { NON_INTERACTIVE=true shift ;; + -ol | --omit-labels) + OMIT_LABELS=true + shift + ;; -h | --help) usage exit @@ -163,11 +168,14 @@ if [ -n "$ORIGINAL_PR_NUMBER" ]; then fi PR_BODY=$(gh api repos/$REPO_UPSTREAM/pulls/$ORIGINAL_PR_NUMBER --jq '"\n\n" + .body') - LABELS=$(get_pr_labels "${REPO_UPSTREAM}" "${ORIGINAL_PR_NUMBER}") - if [ -n "$LABELS" ]; then - LABELS_ARG=(--label "$LABELS") + if [[ "${OMIT_LABELS}" != "true" ]]; then + LABELS=$(get_pr_labels "${REPO_UPSTREAM}" "${ORIGINAL_PR_NUMBER}") + if [[ -n "${LABELS}" ]]; then + LABELS_ARG=(--label "${LABELS}") + fi fi fi + log_info "Creating new PR..." gh pr create \ --base "${BASE_BRANCH}" \