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

Add omit-labels functionality [DOC-268] #15

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion .github/actions/backport/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

Expand Down
14 changes: 11 additions & 3 deletions backport
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down Expand Up @@ -57,6 +58,10 @@ get_opts() {
NON_INTERACTIVE=true
shift
;;
-ol | --omit-labels)
OMIT_LABELS=true
shift
;;
-h | --help)
usage
exit
Expand Down Expand Up @@ -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}" \
Expand Down