|
| 1 | + |
| 2 | +# runs on any comment matching the format `/tag <tagname> <commit>` |
1 | 3 | name: Comment Bot
|
2 | 4 | on:
|
3 | 5 | issue_comment: {types: [created]}
|
4 | 6 | pull_request_review_comment: {types: [created]}
|
5 | 7 | jobs:
|
6 |
| - tag: # /tag <tagname> <commit> |
7 |
| - if: startsWith(github.event.comment.body, '/tag ') |
| 8 | + tag: |
8 | 9 | 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} |
13 | 11 | steps:
|
14 | 12 | - 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