Skip to content

Commit 87dc46c

Browse files
committed
CI: Add workflow to backport changes
Signed-off-by: Tim Meusel <tim@bastelfreak.de>
1 parent 7ba15b4 commit 87dc46c

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/backport.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
name: Backport merged pull request
3+
4+
5+
on:
6+
workflow_call: {}
7+
secrets:
8+
OPENVOXBOT_SSH_PRIVATE_KEY:
9+
description: 'ssh private key to sign commits'
10+
required: true
11+
OPENVOXBOT_COMMIT_AND_PRS:
12+
# Provide a fine-grained token with the following repository permissions:
13+
# * Contents: Read and write
14+
# * Metadata: Read-only (mandatory, default)
15+
# * Pull requests: Read and write
16+
description: 'PAT to access the GitHub API'
17+
required: true
18+
19+
permissions: {}
20+
21+
env:
22+
GIT_AUTHOR_NAME: OpenVoxProjectBot
23+
GIT_AUTHOR_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
24+
GIT_COMMITTER_NAME: OpenVoxProjectBot
25+
GIT_COMMITTER_EMAIL: 215568489+OpenVoxProjectBot@users.noreply.github.com
26+
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
27+
28+
jobs:
29+
backport:
30+
name: Backport merged pull request
31+
runs-on: ubuntu-latest
32+
# For security reasons, we don't want to checkout and run arbitrary code when
33+
# using the pull_request_target trigger. So restrict this to cases where the
34+
# backport label is applied to an already merged PR.
35+
if: github.event.pull_request.merged && startsWith(github.event.label.name, 'backport ')
36+
steps:
37+
- name: Add SSH key
38+
run: |
39+
mkdir -p ~/.ssh
40+
echo "${{ secrets.OPENVOXBOT_SSH_PRIVATE_KEY }}" > ~/.ssh/github_actions
41+
chmod 600 ~/.ssh/github_actions
42+
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
43+
ssh-add ~/.ssh/github_actions
44+
45+
- name: Setup git
46+
run: |
47+
git config --global user.email "$GIT_AUTHOR_EMAIL"
48+
git config --global user.name "$GIT_AUTHOR_NAME"
49+
git config --global gpg.format ssh
50+
git config --global user.signingkey ~/.ssh/github_actions
51+
git config --global commit.gpgsign true
52+
git config --global tag.gpgsign true
53+
- name: Checkout repository
54+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
55+
with:
56+
token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
57+
ref: main
58+
- name: Create backport pull requests
59+
uses: korthout/backport-action@2e830a1d0b8269505846ddd407a70876913ad1f8 # v4.6.0
60+
with:
61+
auto_merge_enabled: true
62+
auto_merge_method: merge
63+
github_token: ${{ secrets.OPENVOXBOT_COMMIT_AND_PRS }}
64+
git_committer_name: OpenVoxProjectBot
65+
git_committer_email: 215568489+OpenVoxProjectBot@users.noreply.github.com

0 commit comments

Comments
 (0)