Skip to content

Commit c3b09bf

Browse files
committed
Add lgtm/remove-lgtm and approve/remove-approve
Signed-off-by: Masaki Kimura <[email protected]>
1 parent c8003e1 commit c3b09bf

13 files changed

+140
-0
lines changed

.github/workflows/command-approve.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: approve command
2+
on:
3+
repository_dispatch:
4+
types: [approve-command]
5+
jobs:
6+
approve:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: mkimuram/test-gha/plugins/approve@main

.github/workflows/command-lgtm.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: lgtm command
2+
on:
3+
repository_dispatch:
4+
types: [lgtm-command]
5+
jobs:
6+
lgtm:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: mkimuram/test-gha/plugins/lgtm@main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: remove-approve command
2+
on:
3+
repository_dispatch:
4+
types: [remove-approve-command]
5+
jobs:
6+
remove-approve:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: mkimuram/test-gha/plugins/remove-approve@main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: remove-lgtm command
2+
on:
3+
repository_dispatch:
4+
types: [remove-lgtm-command]
5+
jobs:
6+
remove-lgtm:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: mkimuram/test-gha/plugins/remove-lgtm@main

.github/workflows/slash-command-dispatch.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
unassign
1919
kind
2020
remove-kind
21+
lgtm
22+
remove-lgtm
23+
approve
24+
remove-approve
2125
retest
2226
meow
2327
woof

plugins/approve/action.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Approve'
2+
description: 'Approves a pull request'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Approves a pull request
7+
shell: bash
8+
run: |
9+
label="approved"
10+
# approve is only for pr
11+
[ -n "${PR_NUM}" ] || false
12+
# TODO: Check if actor has right to approve
13+
# If no args add approved label
14+
if [ -z "${ARGS}" ];then
15+
echo "{\"labels\":[\"${label}\"]}" | \
16+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels -X POST --input -
17+
# If args is cancel remove approved label
18+
elif [[ "${ARGS}" == "cancel" ]];then
19+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels/${label} -X DELETE
20+
fi
21+
env:
22+
REPO: ${{ github.repository }}
23+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
24+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
25+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
26+
GITHUB_TOKEN: ${{ github.token }}

plugins/approve/usage.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| `/lgtm` | `/lgtm [cancel] ` | Adds or removes the 'lgtm' label which is typically used to gate merging. |

plugins/lgtm/action.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Lgtm'
2+
description: 'Add lgtm label to pr'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Add lgtm label to pr
7+
shell: bash
8+
run: |
9+
label="lgtm"
10+
# lgtm is only for pr
11+
[ -n "${PR_NUM}" ] || false
12+
# TODO: Check if actor has right to lgtm
13+
# If no args add lgtm label
14+
if [ -z "${ARGS}" ];then
15+
echo "{\"labels\":[\"${label}\"]}" | \
16+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels -X POST --input -
17+
# If args is cancel remove lgtm label
18+
elif [[ "${ARGS}" == "cancel" ]];then
19+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels/${label} -X DELETE
20+
fi
21+
env:
22+
REPO: ${{ github.repository }}
23+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
24+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
25+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
26+
GITHUB_TOKEN: ${{ github.token }}

plugins/lgtm/usage.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| `/lgtm` | `/lgtm [cancel] ` | Adds or removes the 'lgtm' label which is typically used to gate merging. |

plugins/remove-approve/action.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Remove approve'
2+
description: 'Remove approved label from pr'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Remove approved label from pr
7+
shell: bash
8+
run: |
9+
label="approved"
10+
# remove-approve is only for pr
11+
[ -n "${PR_NUM}" ] || false
12+
# TODO: Check if actor has right to remove-approve
13+
# If no args remove approved label
14+
if [ -z "${ARGS}" ];then
15+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels/${label} -X DELETE
16+
fi
17+
env:
18+
REPO: ${{ github.repository }}
19+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
20+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
21+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
22+
GITHUB_TOKEN: ${{ github.token }}

plugins/remove-approve/usage.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| `/remove-approve` | `/remove-approve ` | Removes the 'approved' label which is typically used to gate merging. |

plugins/remove-lgtm/action.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Remove lgtm'
2+
description: 'Remove lgtm label from pr'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Remove lgtm label from pr
7+
shell: bash
8+
run: |
9+
label="lgtm"
10+
# remove-lgtm is only for pr
11+
[ -n "${PR_NUM}" ] || false
12+
# TODO: Check if actor has right to remove-lgtm
13+
# If no args remove lgtm label
14+
if [ -z "${ARGS}" ];then
15+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels/${label} -X DELETE
16+
fi
17+
env:
18+
REPO: ${{ github.repository }}
19+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
20+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
21+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
22+
GITHUB_TOKEN: ${{ github.token }}

plugins/remove-lgtm/usage.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| `/remove-lgtm` | `/remove-lgtm ` | Removes the 'lgtm' label which is typically used to gate merging. |

0 commit comments

Comments
 (0)