tqdm/.github/workflows/comment-bot.yml

51 lines
2.0 KiB
YAML
Raw Normal View History

2020-07-03 16:54:50 +00:00
name: Comment Bot
on:
2023-03-03 14:36:36 +00:00
issue_comment: {types: [created]}
pull_request_review_comment: {types: [created]}
2020-07-03 16:54:50 +00:00
jobs:
tag: # /tag <tagname> <commit>
2020-07-04 20:26:17 +00:00
if: startsWith(github.event.comment.body, '/tag ')
2020-07-03 16:54:50 +00:00
runs-on: ubuntu-latest
steps:
2023-03-03 14:36:36 +00:00
- uses: actions/checkout@v3
2020-07-03 16:54:50 +00:00
- name: React Seen
2023-03-03 14:36:36 +00:00
uses: actions/github-script@v6
2020-07-03 16:54:50 +00:00
with:
script: |
2023-03-03 14:36:36 +00:00
const perm = await github.rest.repos.getCollaboratorPermissionLevel({
2020-07-03 16:54:50 +00:00
owner: context.repo.owner, repo: context.repo.repo,
username: context.payload.comment.user.login})
post = (context.eventName == "issue_comment"
2023-03-03 14:36:36 +00:00
? github.rest.reactions.createForIssueComment
: github.rest.reactions.createForPullRequestReviewComment)
2020-07-04 20:26:17 +00:00
if (!["admin", "write"].includes(perm.data.permission)){
2020-07-03 16:54:50 +00:00
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"})
2021-05-24 12:09:57 +00:00
github-token: ${{ secrets.GH_TOKEN }}
2020-07-03 16:54:50 +00:00
- 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
2023-03-03 14:36:36 +00:00
uses: actions/github-script@v6
2020-07-03 16:54:50 +00:00
with:
script: |
post = (context.eventName == "issue_comment"
2023-03-03 14:36:36 +00:00
? github.rest.reactions.createForIssueComment
: github.rest.reactions.createForPullRequestReviewComment)
2020-07-03 16:54:50 +00:00
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
2021-05-24 12:09:57 +00:00
github-token: ${{ secrets.GH_TOKEN }}