Skip to content

Commit 59baef3

Browse files
committed
Add commands
1 parent d354770 commit 59baef3

15 files changed

+638
-0
lines changed

.github/labels.json

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"type": {
3+
"kind": [
4+
{
5+
"name": "bug",
6+
"color": "D73A4A",
7+
"description": "Categorizes issue or PR as related to a bug."
8+
},
9+
{
10+
"name": "feature",
11+
"color": "A2EEEF",
12+
"description": "Categorizes issue or PR as related to a new feature."
13+
},
14+
{
15+
"name": "documentation",
16+
"color": "A2EEEF",
17+
"description": "Categorizes issue or PR as related to documentation."
18+
}
19+
],
20+
"priority": [
21+
{
22+
"name": "awaiting-more-evidence",
23+
"color": "FEF2C0",
24+
"description": "Lowest priority. Possibly useful, but not yet enough support to actually get it done."
25+
},
26+
{
27+
"name": "backlog",
28+
"color": "FBCA04",
29+
"description": "Higher priority than priority/awaiting-more-evidence."
30+
},
31+
{
32+
"name": "critical-urgent",
33+
"color": "B60205",
34+
"description": "Highest priority. Must be actively worked on as someone's top priority right now."
35+
},
36+
{
37+
"name": "important-longterm",
38+
"color": "E99695",
39+
"description": "Important over the long term, but may not be staffed and/or may need multiple releases to complete."
40+
},
41+
{
42+
"name": "important-soon",
43+
"color": "E99695",
44+
"description": "Must be staffed and worked on either currently, or very soon, ideally in time for the next release."
45+
}
46+
],
47+
"lifecycle": [
48+
{
49+
"name": "active",
50+
"color": "C2E0C6",
51+
"description": "Indicates that an issue or PR is actively being worked on by a contributor."
52+
},
53+
{
54+
"name": "frozen",
55+
"color": "BFD4F2",
56+
"description": "Indicates that an issue or PR should not be auto-closed due to staleness."
57+
},
58+
{
59+
"name": "rotten",
60+
"color": "87401D",
61+
"description": "Denotes an issue or PR that has aged beyond stale and will be auto-closed."
62+
},
63+
{
64+
"name": "stale",
65+
"color": "87401D",
66+
"description": "Denotes an issue or PR has remained open with no activity and has become stale."
67+
}
68+
],
69+
"sig": [
70+
],
71+
"area": [
72+
],
73+
"wg": [
74+
],
75+
"": [
76+
{
77+
"name": "lgtm",
78+
"color": "0E8A16",
79+
"description": "Indicates that a PR is ready to be merged."
80+
},
81+
{
82+
"name": "approved",
83+
"color": "0E8A16",
84+
"description": "Indicates a PR has been approved by an approver."
85+
},
86+
{
87+
"name": "ok-to-test",
88+
"color": "0E8A16",
89+
"description": "Indicates a non-member PR verified by an org member that is safe to test."
90+
}
91+
]
92+
}
93+
}

.github/workflows/command-assign.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Usage: | `/assgin` | `/assign`<br> `/assign spongebob patrick` | Assigns assignee(s) to the PR. |
2+
name: assign command
3+
on:
4+
repository_dispatch:
5+
types: [assign-command]
6+
jobs:
7+
assign:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Assign to issue or pr
11+
run: |
12+
if [ -n "${ARGS}" ];then
13+
i=0
14+
for person in ${ARGS};do
15+
if [ $i -ne 0 ];then
16+
people="${people}, "
17+
fi
18+
people="${people}\"${person}\""
19+
i=`expr $i + 1`
20+
done
21+
else
22+
people="\"${{ github.actor }}\""
23+
fi
24+
25+
echo "{\"assignees\":[${people}]}" | \
26+
gh api repos/${REPO}/issues/${ISSUE_NUM}/assignees -X POST --input -
27+
env:
28+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
29+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
30+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
31+
GITHUB_TOKEN: ${{secrets.PAT}}

.github/workflows/command-close.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Usage: | `/close` | `/close` | Closes an issue or PR. |
2+
name: close command
3+
on:
4+
repository_dispatch:
5+
types: [close-command]
6+
jobs:
7+
close:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Close issue or pr
11+
run: |
12+
if [ -n "${PR_NUM}" ];then
13+
gh pr close "${PR_NUM}" -R ${REPO}
14+
else
15+
gh issue close ${ISSUE_NUM} -R ${REPO}
16+
fi
17+
env:
18+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
19+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
20+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
21+
GITHUB_TOKEN: ${{secrets.PAT}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: ensure-labels command
2+
on:
3+
repository_dispatch:
4+
types: [ensure-labels-command]
5+
jobs:
6+
assign:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Ensure labels
11+
run: |
12+
file=".github/labels.json"
13+
repo=${{ github.event.client_payload.github.payload.repository.full_name }}
14+
for t in $(jq -r ".type | keys | .[]" ${file});do
15+
v=$(jq -r ".type[\"${t}\"][]" ${file})
16+
for name in $(jq -r ".name" <<< ${v} );do
17+
color=$(jq -r ". | select(.name == \"${name}\") | .color" <<< ${v} )
18+
desc=$(jq -r ". | select(.name == \"${name}\") | .description" <<< ${v} )
19+
# Create data to send
20+
data="{"
21+
if [ -n "${t}" ];then
22+
data="${data}\"name\":\"${t}/${name}\""
23+
else
24+
data="${data}\"name\":\"${name}\""
25+
fi
26+
if [ -n "${color}" ];then
27+
data="${data}, \"color\":\"${color}\""
28+
fi
29+
if [ -n "${desc}" ];then
30+
data="${data}, \"description\":\"${desc}\""
31+
fi
32+
data="${data}}"
33+
# Send data
34+
curl \
35+
-X POST \
36+
-H "Accept: application/vnd.github.v3+json" \
37+
-H "Authorization: token ${{ secrets.PAT }}" \
38+
https://api.github.com/repos/${repo}/labels \
39+
-d "${data}"
40+
done
41+
done

.github/workflows/command-harray.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: hooray command
2+
on:
3+
repository_dispatch:
4+
types: [hooray-command]
5+
jobs:
6+
hooray:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Add reaction
10+
uses: peter-evans/create-or-update-comment@v1
11+
with:
12+
token: ${{ secrets.PAT }}
13+
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
14+
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
15+
reaction-type: hooray

.github/workflows/command-kind.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Usage: | `/kind` | `/kind bug` | Applies a kind label. |
2+
name: kind command
3+
on:
4+
repository_dispatch:
5+
types: [kind-command]
6+
jobs:
7+
kind:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Add kind label to issue or pr
11+
run: |
12+
# args should not be empty
13+
[ -n "${ARGS}" ] || false
14+
# args should only contain one value
15+
[[ "${ARGS}" != *" "* ]] || false
16+
label="kind/${ARGS}"
17+
echo "{\"labels\":[\"${label}\"]}" | \
18+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels -X POST --input -
19+
env:
20+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
21+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
22+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
23+
GITHUB_TOKEN: ${{secrets.PAT}}

.github/workflows/command-meow.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Usage: | `/meow` | `/meow` | Add a cat image to the issue or PR. |
2+
name: meow command
3+
on:
4+
repository_dispatch:
5+
types: [meow-command]
6+
jobs:
7+
meow:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Show a cat image
11+
run: |
12+
img=$(curl -s 'https://api.thecatapi.com/v1/images/search?format=json' | jq '.[0].url')
13+
msg="<img src=${img} width=\"150\">"
14+
if [ -n "${PR_NUM}" ];then
15+
gh pr comment "${PR_NUM}" -R ${REPO} -b "${msg}"
16+
else
17+
gh issue comment "${ISSUE_NUM}" -R ${REPO} -b "${msg}"
18+
fi
19+
env:
20+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
21+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
22+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
23+
GITHUB_TOKEN: ${{secrets.PAT}}

.github/workflows/command-pony.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Usage: | `/pony` | `/pony` | Add a pony image to the issue or PR. |
2+
name: pony command
3+
on:
4+
repository_dispatch:
5+
types: [pony-command]
6+
jobs:
7+
pony:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Show a pony image
11+
run: |
12+
img=$(curl -s 'https://theponyapi.com/api/v1/pony/random' | jq '.pony.representations.small')
13+
msg="<img src=${img} width=\"150\">"
14+
if [ -n "${PR_NUM}" ];then
15+
gh pr comment "${PR_NUM}" -R ${REPO} -b "${msg}"
16+
else
17+
gh issue comment "${ISSUE_NUM}" -R ${REPO} -b "${msg}"
18+
fi
19+
env:
20+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
21+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
22+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
23+
GITHUB_TOKEN: ${{secrets.PAT}}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Usage: | `/remove-kind` | `/remove-kind bug` | Removes a kind label. |
2+
name: remove kind command
3+
on:
4+
repository_dispatch:
5+
types: [remove-kind-command]
6+
jobs:
7+
remove-kind:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Remove kind label from issue or pr
11+
run: |
12+
# args should not be empty
13+
[ -n "${ARGS}" ] || false
14+
# args should only contain one value
15+
[[ "${ARGS}" != *" "* ]] || false
16+
label="kind/${ARGS}"
17+
gh api repos/${REPO}/issues/${ISSUE_NUM}/labels/${label} -X DELETE
18+
env:
19+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
20+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
21+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
22+
GITHUB_TOKEN: ${{secrets.PAT}}

.github/workflows/command-reopen.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Usage: | `/reopen` | `/reopen` | Reopens an issue or PR. |
2+
name: reopen command
3+
on:
4+
repository_dispatch:
5+
types: [reopen-command]
6+
jobs:
7+
reopen:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Reopen issue or pr
11+
run: |
12+
if [ -n "${PR_NUM}" ];then
13+
gh pr reopen "${PR_NUM}" -R ${REPO}
14+
else
15+
gh issue reopen ${ISSUE_NUM} -R ${REPO}
16+
fi
17+
env:
18+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
19+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
20+
PR_NUM: ${{ github.event.client_payload.pull_request.number }}
21+
GITHUB_TOKEN: ${{secrets.PAT}}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Usage: | `/unassgin` | `/unassign`<br> `/unassign spongebob patrick` | Unassigns assignee(s) from the PR. |
2+
name: unassign command
3+
on:
4+
repository_dispatch:
5+
types: [unassign-command]
6+
jobs:
7+
unassign:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Unassign from issue or pr
11+
run: |
12+
if [ -n "${ARGS}" ];then
13+
i=0
14+
for person in ${ARGS};do
15+
if [ $i -ne 0 ];then
16+
people="${people}, "
17+
fi
18+
people="${people}\"${person}\""
19+
i=`expr $i + 1`
20+
done
21+
else
22+
people="\"${{ github.actor }}\""
23+
fi
24+
25+
echo "{\"assignees\":[${people}]}" | \
26+
gh api repos/${REPO}/issues/${ISSUE_NUM}/assignees -X DELETE --input -
27+
env:
28+
REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
29+
ISSUE_NUM: ${{ github.event.client_payload.github.payload.issue.number }}
30+
ARGS: ${{ github.event.client_payload.slash_command.args.unnamed.all }}
31+
GITHUB_TOKEN: ${{secrets.PAT}}

0 commit comments

Comments
 (0)