-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Comment Bot | ||
on: | ||
issue_comment: | ||
types: [created] | ||
pull_request_review_comment: | ||
types: [created] | ||
jobs: | ||
tag: # /tag <tagname> <commit> | ||
if: startsWith(github.event.comment.body, '/tag ') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: React Seen | ||
uses: actions/github-script@v2 | ||
with: | ||
script: | | ||
const perm = await github.repos.getCollaboratorPermissionLevel({ | ||
owner: context.repo.owner, repo: context.repo.repo, | ||
username: context.payload.comment.user.login}) | ||
post = (context.eventName == "issue_comment" | ||
? github.reactions.createForIssueComment | ||
: github.reactions.createForPullRequestReviewComment) | ||
if (!["admin", "write"].includes(perm.data.permission)){ | ||
post({ | ||
owner: context.repo.owner, repo: context.repo.repo, | ||
comment_id: context.payload.comment.id, content: "laugh"}) | ||
throw "Permission denied for user " + context.payload.comment.user.login | ||
} | ||
post({ | ||
owner: context.repo.owner, repo: context.repo.repo, | ||
comment_id: context.payload.comment.id, content: "eyes"}) | ||
- name: Tag Commit | ||
run: | | ||
git clone https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} repo | ||
git -C repo tag $(echo "$BODY" | awk '{print $2" "$3}') | ||
git -C repo push --tags | ||
rm -rf repo | ||
env: | ||
BODY: ${{ github.event.comment.body }} | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
- name: React Success | ||
uses: actions/github-script@v2 | ||
with: | ||
script: | | ||
post = (context.eventName == "issue_comment" | ||
? github.reactions.createForIssueComment | ||
: github.reactions.createForPullRequestReviewComment) | ||
post({ | ||
owner: context.repo.owner, repo: context.repo.repo, | ||
comment_id: context.payload.comment.id, content: "rocket"}) |