Skip to content

Commit 534a712

Browse files
authored
Merge pull request #90 from OpenVoxProject/backport
CI: Add backport workflow & Enable automerge for dependabot/renovate
2 parents 292a1b7 + 03ef741 commit 534a712

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/backport.yml

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

.github/workflows/tests.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,20 @@ jobs:
7373
uses: re-actors/alls-green@release/v1
7474
with:
7575
jobs: ${{ toJSON(needs) }}
76+
77+
automerge:
78+
name: Enable auto-merge
79+
if: github.event_name == 'pull_request' && (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'renovate[bot]')
80+
needs:
81+
- tests
82+
runs-on: ubuntu-24.04
83+
permissions:
84+
contents: write
85+
pull-requests: write
86+
steps:
87+
- name: Enable auto-merge for PR
88+
env:
89+
GH_TOKEN: ${{ github.token }}
90+
PR_URL: ${{ github.event.pull_request.html_url }}
91+
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
92+
run: gh pr merge --auto --merge --match-head-commit "$PR_HEAD_SHA" "$PR_URL"

0 commit comments

Comments
 (0)