|
9 | 9 | types: [closed, labeled] |
10 | 10 | branches: |
11 | 11 | - main |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + backport-branch: |
| 15 | + description: "Branch to backport commits onto" |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + pull-request: |
| 19 | + description: "PR to backport" |
| 20 | + required: true |
| 21 | + type: number |
| 22 | + |
12 | 23 |
|
13 | 24 | permissions: |
14 | 25 | contents: write # so it can comment |
15 | 26 | pull-requests: write # so it can create pull requests |
16 | 27 |
|
17 | 28 | jobs: |
18 | | - backport: |
19 | | - name: Backport pull request |
| 29 | + backport-from-pr: |
| 30 | + name: Backport directly from a pull request |
20 | 31 | if: ${{ github.repository_owner == 'nvidia' && |
21 | 32 | github.event.pull_request.merged == true && |
22 | 33 | contains( github.event.pull_request.labels.*.name, 'to-be-backported') |
|
38 | 49 | copy_labels_pattern: true |
39 | 50 | copy_requested_reviewers: true |
40 | 51 | target_branches: ${{ env.OLD_BRANCH }} |
| 52 | + backport-to-branch: |
| 53 | + name: Backport a specific PR against a specific branch |
| 54 | + if: github.repository_owner == 'nvidia' && github.event_name == 'workflow_dispatch' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 58 | + |
| 59 | + - name: Load branch from environment name |
| 60 | + if: inputs.backport-branch == null |
| 61 | + run: | |
| 62 | + BACKPORT_BRANCH=$(yq '.backport_branch' ci/versions.yml) |
| 63 | + echo "BACKPORT_BRANCH=${BRANCH}" >> $GITHUB_ENV |
| 64 | +
|
| 65 | + - name: Load branch name from input |
| 66 | + if: inputs.backport-branch != null |
| 67 | + run: echo "BACKPORT_BRANCH=${{ inputs.backport-branch }}" >> $GITHUB_ENV |
| 68 | + |
| 69 | + - name: Create backport pull requests |
| 70 | + uses: korthout/backport-action@c656f5d5851037b2b38fb5db2691a03fa229e3b2 # v4.0.1 |
| 71 | + with: |
| 72 | + copy_assignees: true |
| 73 | + copy_labels_pattern: true |
| 74 | + copy_requested_reviewers: true |
| 75 | + target_branches: ${{ env.BACKPORT_BRANCH }} |
| 76 | + source_pr_number: ${{ inputs.pull-request }} |
0 commit comments