-
Notifications
You must be signed in to change notification settings - Fork 4
79 lines (65 loc) · 2.49 KB
/
automatic-rebase.yml
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
on:
issue_comment:
types:
- created
pull_request_target:
types:
- auto_merge_enabled
env:
AUTO_REBASE_PERSONAL_ACCESS_TOKEN:
${{ secrets.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
jobs:
check-token:
if: |
(
github.event.issue.pull_request &&
contains(github.event.comment.body, '/rebase')
) ||
github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
- if: "! env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN"
name: Prompt to add a token
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number || github.event.number }}
body: |
To automatically rebase, you need to add a [personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with the name `AUTO_REBASE_PERSONAL_ACCESS_TOKEN` to the [secrets section of this repo](https://github.com/${{ github.event.repository.full_name }}/settings/secrets/actions).
Once this is done, you can try the `/rebase` command again.
- if: github.event.comment
name: React to the triggering comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.comment.id }}
reactions:
${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN && '+1' || '-1' }}
- if: "! env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN"
name: Return a failing state if we have no token
run: exit 1
rebase:
needs: check-token
name: Rebase
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
fetch-depth: 0
- name: Rebase on top of the default branch
uses: cirrus-actions/[email protected]
env:
GITHUB_TOKEN: ${{ env.AUTO_REBASE_PERSONAL_ACCESS_TOKEN }}
- if: failure()
name: Notify of the failure
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number || github.event.number }}
body: |
Automatic rebasing for this issue has failed :disappointed:
You'll have to rebase this one manually, I'm afraid.
- if: success() && github.event.comment
name: React to the triggering comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.comment.id }}
reactions: hooray