Skip to content

Commit 5da4377

Browse files
authored
Add backport PR GHA (#1809)
* testing backport pr * testing conditions run without merge * more testing conditions * trying app token * test on branch * add workflow dispatch * switch to pull_request for testing * cleaning up * trigger workflow in 2 scenarios 1. pr labeled after merge, merge action 2. pr merged but label is already present
1 parent 0283be3 commit 5da4377

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/backport-pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Backport PR
2+
on:
3+
pull_request:
4+
types: [ labeled, closed ]
5+
6+
permissions: {}
7+
8+
jobs:
9+
backport:
10+
name: Backport PR
11+
runs-on: ubuntu-latest
12+
if: >
13+
github.event.pull_request.merged
14+
&& (
15+
( github.event.action == 'closed' && contains(github.event.label.name, 'backport') )
16+
||
17+
( github.event.action == 'labeled' && contains(github.event.label.name, 'backport') )
18+
)
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
steps:
23+
- uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1.11.6
24+
id: app-token
25+
with:
26+
app-id: ${{ vars.DD_GITHUB_TOKEN_GENERATOR_APP_ID }}
27+
private-key: ${{ secrets.DD_GITHUB_TOKEN_GENERATOR_PRIVATE_KEY }}
28+
- uses: tibdex/backport@9565281eda0731b1d20c4025c43339fb0a23812e # v2.0.4
29+
with:
30+
label_pattern: "^backport/(?<base>([^ ]+))$"
31+
labels_template: "<%= JSON.stringify([...labels, 'backport', 'bot']) %>"
32+
github_token: ${{ steps.app-token.outputs.token }}
33+
title_template: "[ Backport <%- base %> ] <%- title %>"
34+
body_template: |
35+
Backport <%- mergeCommitSha %> from #<%- number %>.
36+
37+
___
38+
39+
<%- body %>

0 commit comments

Comments
 (0)