forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (121 loc) · 5.29 KB
/
backport.yaml
File metadata and controls
130 lines (121 loc) · 5.29 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Pull Request backporting
on:
pull_request_target:
types:
- closed
- labeled
jobs:
backport_v1:
name: "Backport to v1"
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
&& contains(github.event.pull_request.labels.*.name, 'backport-v1')
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport-v1')
)
)
runs-on: ubuntu-latest
steps:
- name: Generate a token from the gophercloud-backport-bot github-app
id: generate_token
uses: getsentry/action-github-app-token@a0061014b82a6a5d6aeeb3b824aced47e3c3a7ef
with:
app_id: ${{ secrets.BACKPORT_APP_ID }}
private_key: ${{ secrets.BACKPORT_APP_PRIVATE_KEY }}
- name: Backporting
if: >
contains(github.event.pull_request.labels.*.name, 'semver:patch')
|| contains(github.event.label.name, 'semver:patch')
uses: kiegroup/git-backporting@b9ed3ac959d1479e81bf4f0a5e5f0a72251ce895
with:
target-branch: v1
pull-request: ${{ github.event.pull_request.url }}
auth: ${{ steps.generate_token.outputs.token }}
no-squash: true
strategy-option: find-renames
- name: Report failure
if: failure()
run: gh issue comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
BODY: >
Failed to backport PR to `v1` branch. See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
- name: Report an error if backport unsupported labels
if: >
contains(github.event.pull_request.labels.*.name, 'semver:major')
|| contains(github.event.pull_request.labels.*.name, 'semver:minor')
|| contains(github.event.pull_request.labels.*.name, 'semver:unknown')
|| contains(github.event.label.name, 'semver:major')
|| contains(github.event.label.name, 'semver:minor')
|| contains(github.event.label.name, 'semver:unknown')
run: gh pr comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
BODY: >
Labels `semver-major`, `semver-minor` and `semver-unknown` block backports to the legacy branch `v1`.
backport_v2:
name: "Backport to v2"
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
&& contains(github.event.pull_request.labels.*.name, 'backport-v2')
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport-v2')
)
)
runs-on: ubuntu-latest
steps:
- name: Generate a token from the gophercloud-backport-bot github-app
id: generate_token
uses: getsentry/action-github-app-token@a0061014b82a6a5d6aeeb3b824aced47e3c3a7ef
with:
app_id: ${{ secrets.BACKPORT_APP_ID }}
private_key: ${{ secrets.BACKPORT_APP_PRIVATE_KEY }}
- name: Backporting
if: >
contains(github.event.pull_request.labels.*.name, 'semver:patch')
|| contains(github.event.pull_request.labels.*.name, 'semver:minor')
|| contains(github.event.label.name, 'semver:patch')
|| contains(github.event.label.name, 'semver:minor')
uses: kiegroup/git-backporting@b9ed3ac959d1479e81bf4f0a5e5f0a72251ce895
with:
target-branch: v2
pull-request: ${{ github.event.pull_request.url }}
auth: ${{ steps.generate_token.outputs.token }}
no-squash: true
strategy-option: find-renames
- name: Report failure
if: failure()
run: gh issue comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
BODY: >
Failed to backport PR to `v2` branch. See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
- name: Report an error if backport unsupported labels
if: >
contains(github.event.pull_request.labels.*.name, 'semver:major')
|| contains(github.event.pull_request.labels.*.name, 'semver:unknown')
|| contains(github.event.label.name, 'semver:major')
|| contains(github.event.label.name, 'semver:unknown')
run: gh pr comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.pull_request.number }}
BODY: >
Labels `semver-major` and `semver-unknown` block backports to the stable branch `v2`.