Repository navigation
59 lines (49 loc) · 1.83 KB
/
Copy pathforward-port-trigger.yml
File metadata and controls
59 lines (49 loc) · 1.83 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
name: "Forward Port Trigger"
on:
pull_request:
types: [closed]
permissions:
contents: read
pull-requests: write
jobs:
forward-port:
if: >-
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'needs_forward_port') &&
github.event.pull_request.base.ref != 'main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
with:
python-version: "3.x"
- name: Derive forward-port targets
id: targets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
PYTHONPATH: scripts
run: |
BASE="${{ github.event.pull_request.base.ref }}"
TARGETS=$(python3 -c "
from release_automation.helpers import forward_port_targets
targets = forward_port_targets('$BASE', '${{ github.repository }}', include_main=False)
print(' '.join(targets))
")
echo "Forward-port targets for $BASE: $TARGETS"
echo "targets=$TARGETS" >> "$GITHUB_OUTPUT"
- name: Post backport command for forward-port
if: steps.targets.outputs.targets != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUM="${{ github.event.pull_request.number }}"
TARGETS="${{ steps.targets.outputs.targets }}"
COMMENT="/backport $TARGETS"
echo "Posting: $COMMENT"
gh pr comment "$PR_NUM" --repo "${{ github.repository }}" --body "$COMMENT"
- name: No targets
if: steps.targets.outputs.targets == ''
run: echo "No forward-port target branches found — nothing to do."