Skip to content

Commit 9ec76e7

Browse files
committed
CI: use external comment-bot
1 parent 1767b28 commit 9ec76e7

File tree

1 file changed

+6
-44
lines changed

1 file changed

+6
-44
lines changed

.github/workflows/comment-bot.yml

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
1+
2+
# runs on any comment matching the format `/tag <tagname> <commit>`
13
name: Comment Bot
24
on:
35
issue_comment: {types: [created]}
46
pull_request_review_comment: {types: [created]}
57
jobs:
6-
tag: # /tag <tagname> <commit>
7-
if: startsWith(github.event.comment.body, '/tag ')
8+
tag:
89
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
11-
pull-requests: write
12-
issues: write
10+
permissions: {contents: write, pull-requests: write, issues: write}
1311
steps:
1412
- uses: actions/checkout@v4
15-
- name: React Seen
16-
uses: actions/github-script@v7
17-
with:
18-
script: |
19-
const perm = await github.rest.repos.getCollaboratorPermissionLevel({
20-
owner: context.repo.owner, repo: context.repo.repo,
21-
username: context.payload.comment.user.login})
22-
post = (context.eventName == "issue_comment"
23-
? github.rest.reactions.createForIssueComment
24-
: github.rest.reactions.createForPullRequestReviewComment)
25-
if (!["admin", "write"].includes(perm.data.permission)){
26-
post({
27-
owner: context.repo.owner, repo: context.repo.repo,
28-
comment_id: context.payload.comment.id, content: "laugh"})
29-
throw "Permission denied for user " + context.payload.comment.user.login
30-
}
31-
post({
32-
owner: context.repo.owner, repo: context.repo.repo,
33-
comment_id: context.payload.comment.id, content: "eyes"})
34-
- name: Tag Commit
35-
run: |
36-
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo
37-
git -C repo tag $(echo "$BODY" | awk '{print $2" "$3}')
38-
git -C repo push --tags
39-
rm -rf repo
40-
env:
41-
BODY: ${{ github.event.comment.body }}
42-
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
43-
- name: React Success
44-
uses: actions/github-script@v7
45-
with:
46-
script: |
47-
post = (context.eventName == "issue_comment"
48-
? github.rest.reactions.createForIssueComment
49-
: github.rest.reactions.createForPullRequestReviewComment)
50-
post({
51-
owner: context.repo.owner, repo: context.repo.repo,
52-
comment_id: context.payload.comment.id, content: "rocket"})
13+
with: {fetch-depth: 0}
14+
- uses: casperdcl/comment-bot@v1

0 commit comments

Comments
 (0)