-
-
Notifications
You must be signed in to change notification settings - Fork 161
78 lines (69 loc) · 2.5 KB
/
Copy pathon_label.yml
File metadata and controls
78 lines (69 loc) · 2.5 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
77
78
# Heavily inspired by https://github.com/NixOS/nixpkgs/blob/a698ac1214cd924d4394ca9cd2691618765aa03c/.github/workflows/backport.yml
name: "On Backport Label"
on:
pull_request_target:
types:
- closed
- labeled
permissions:
actions: write
contents: write
pull-requests: write
jobs:
backport:
if: github.event.pull_request.labels && contains(join(github.event.pull_request.labels.*.name, ', '), 'backport ')
name: Backport PR 🔙
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
created_pull_numbers: ${{ steps.backport.outputs.created_pull_numbers }}
steps:
- name: Check actor permissions
id: check-permissions
uses: prince-chrismc/check-actor-permissions-action@d504e74ba31658f4cdf4fcfeb509d4c09736d88e # v3.0.2
with:
permission: write
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Create backport PR
id: backport
uses: korthout/backport-action@66065406958f46e82238fd59546f5a99e69e22aa # v4.5.2
with:
merge_commits: "skip"
add_author_as_assignee: true
copy_requested_reviewers: true
trigger-ci:
name: Trigger CI on created branches 🚀
needs: backport
if: github.event.pull_request.labels && contains(join(github.event.pull_request.labels.*.name, ', '), 'backport ') && needs.backport.outputs.created_pull_numbers != ''
strategy:
matrix:
pr: ${{ fromJSON(format('[{0}]', needs.backport.outputs.created_pull_numbers)) }}
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Get PR branch
id: branch
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "branch=$(gh pr view ${{ matrix.pr }} --json headRefName -q .headRefName)" >> $GITHUB_OUTPUT
- name: Dispatch workflow
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'on_push.yml',
ref: '${{ steps.branch.outputs.branch }}',
inputs: {
pr_number: '${{ matrix.pr }}',
post_result: 'true'
}
})