Skip to content

Commit 84745ab

Browse files
authored
ci: add GitHub workflow for automatic PR rebase (#1243)
Add a GitHub Actions workflow to enable automatic rebasing of pull requests via comment commands `/rebase` and `/autosquash` The workflow allows repository collaborators to trigger a rebase of a pull request by commenting `/rebase` or perform an autosquash rebase with `/autosquash`. Signed-off-by: drivebyer <wuyangmuc@gmail.com>
1 parent 6264dae commit 84745ab

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

.github/workflows/auto-rebase.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Automatic Rebase
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
rebase:
9+
name: Rebase
10+
if: >-
11+
github.event.issue.pull_request != '' &&
12+
(
13+
contains(github.event.comment.body, '/rebase') ||
14+
contains(github.event.comment.body, '/autosquash')
15+
)
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
steps:
21+
- name: Checkout the latest code
22+
uses: actions/checkout@v4
23+
with:
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
fetch-depth: 0
26+
- name: Automatic Rebase
27+
uses: cirrus-actions/rebase@1.8
28+
with:
29+
autosquash: ${{ contains(github.event.comment.body, '/autosquash') || contains(github.event.comment.body, '/rebase-autosquash') }}
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)