Skip to content

Commit

Permalink
CI: clean up tag-bot
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Feb 20, 2024
1 parent 3b4d692 commit 62e4994
Showing 1 changed file with 7 additions and 44 deletions.
51 changes: 7 additions & 44 deletions .github/workflows/comment-bot.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,17 @@
# runs on any comment matching the format `/tag <tagname> <commit>`
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 ')
tag:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
permissions: {contents: write, pull-requests: write, issues: write}
steps:
- uses: actions/checkout@v4
- name: React Seen
uses: actions/github-script@v7
with:
script: |
const perm = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner, repo: context.repo.repo,
username: context.payload.comment.user.login})
post = (context.eventName == "issue_comment"
? github.rest.reactions.createForIssueComment
: github.rest.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"})
github-token: ${{ secrets.GH_TOKEN || github.token }}
- 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 || github.token }}
- name: React Success
uses: actions/github-script@v7
fetch-depth: 0
token: ${{ secrets.GH_TOKEN || github.token }}
- uses: casperdcl/comment-bot@v1
with:
script: |
post = (context.eventName == "issue_comment"
? github.rest.reactions.createForIssueComment
: github.rest.reactions.createForPullRequestReviewComment)
post({
owner: context.repo.owner, repo: context.repo.repo,
comment_id: context.payload.comment.id, content: "rocket"})
github-token: ${{ secrets.GH_TOKEN || github.token }}
token: ${{ secrets.GH_TOKEN || github.token }}

0 comments on commit 62e4994

Please sign in to comment.