-
Notifications
You must be signed in to change notification settings - Fork 264
76 lines (66 loc) · 2.52 KB
/
backport.yml
File metadata and controls
76 lines (66 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: "CI: Backport the merged PR"
on:
pull_request_target:
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-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')
}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Load branch name
id: get-branch
run: |
OLD_BRANCH=$(yq '.backport_branch' ci/versions.yml)
echo "OLD_BRANCH=${OLD_BRANCH}" >> $GITHUB_ENV
- name: Create backport pull requests
uses: korthout/backport-action@3c06f323a58619da1e8522229ebc8d5de2633e46 # v4.3.0
with:
copy_assignees: true
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- 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@3c06f323a58619da1e8522229ebc8d5de2633e46 # v4.3.0
with:
copy_assignees: true
copy_labels_pattern: true
copy_requested_reviewers: true
target_branches: ${{ env.BACKPORT_BRANCH }}
source_pr_number: ${{ inputs.pull-request }}