-
Notifications
You must be signed in to change notification settings - Fork 50
69 lines (59 loc) · 2.31 KB
/
fast-forward.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
name: Fast Forward Merge
on:
issue_comment:
types: [ created ]
jobs:
fast_forward_job:
name: Fast Forward
if: |
(github.event.issue.pull_request != '') &&
github.event.comment.body == '/fast-forward'
runs-on: ubuntu-latest
steps:
- uses: actions-cool/check-user-permission@v2
id: has_permission
with:
require: 'write'
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
if: steps.has_permission.outputs.require-result != 'true'
with:
pr-number: ${{ github.event.issue.number }}
message: |
You have no write permission on this repository
- name: Exit if no write permission
if: steps.has_permission.outputs.require-result != 'true'
run: exit 1
- uses: actions/github-script@v7
id: current_pr
with:
github-token: ${{ secrets.FAST_FORWARD_TOKEN }}
script: |
return github.rest.pulls.get({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
- run: echo $prJSON
env:
prJSON: ${{ toJSON(fromJSON(steps.current_pr.outputs.result).data) }}
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
if: fromJSON(steps.current_pr.outputs.result).data.mergeable_state != 'clean'
with:
pr-number: ${{ github.event.issue.number }}
message: |
The PR mergeable_state needs to be clean, was: ${{ fromJSON(steps.current_pr.outputs.result).data.mergeable_state }}
- name: Exit if PR mergeable_state is not clean
if: fromJSON(steps.current_pr.outputs.result).data.mergeable_state != 'clean'
run: exit 1
# To use this repository's private action, you must check out the repository
- name: Checkout
uses: actions/checkout@v4
- name: Fast Forward PR
id: ff-action
uses: endre-spotlab/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.FAST_FORWARD_TOKEN }}
success_message: 'Success! Fast forwarded ***target_base*** to ***source_head***! ```git checkout target_base && git merge source_head --ff-only``` '
failure_message: 'Failed! Cannot do fast forward!'