From 486d73ca024355bbb8eeb7b1c2473d3d2bda0927 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Tue, 13 Jan 2026 13:38:54 -0500 Subject: [PATCH] ci: allow backporting directly from the github ui --- .github/workflows/backport.yml | 40 ++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index c06ac0d120..a575779d56 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -9,14 +9,25 @@ on: types: [closed, labeled] branches: - main + workflow_dispatch: + inputs: + backport-branch: + description: "Branch to backport commits onto" + required: false + type: string + pull-request: + description: "PR to backport" + required: true + type: number + permissions: contents: write # so it can comment pull-requests: write # so it can create pull requests jobs: - backport: - name: Backport pull request + backport-from-pr: + name: Backport directly from a pull request if: ${{ github.repository_owner == 'nvidia' && github.event.pull_request.merged == true && contains( github.event.pull_request.labels.*.name, 'to-be-backported') @@ -38,3 +49,28 @@ jobs: copy_labels_pattern: true copy_requested_reviewers: true target_branches: ${{ env.OLD_BRANCH }} + backport-to-branch: + name: Backport a specific PR against a specific branch + if: github.repository_owner == 'nvidia' && github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + + - name: Load branch from environment name + if: inputs.backport-branch == null + run: | + BACKPORT_BRANCH=$(yq '.backport_branch' ci/versions.yml) + echo "BACKPORT_BRANCH=${BRANCH}" >> $GITHUB_ENV + + - name: Load branch name from input + if: inputs.backport-branch != null + run: echo "BACKPORT_BRANCH=${{ inputs.backport-branch }}" >> $GITHUB_ENV + + - name: Create backport pull requests + uses: korthout/backport-action@c656f5d5851037b2b38fb5db2691a03fa229e3b2 # v4.0.1 + with: + copy_assignees: true + copy_labels_pattern: true + copy_requested_reviewers: true + target_branches: ${{ env.BACKPORT_BRANCH }} + source_pr_number: ${{ inputs.pull-request }}