forked from Submitty/Submitty
-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (32 loc) · 1.34 KB
/
Copy pathfirst_issue_reply.yml
File metadata and controls
38 lines (32 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: First issue reply
on:
issue_comment:
types: [created]
jobs:
firstIssueReply:
# Only when it is an issue rather than a PR
if: ${{ !github.event.issue.pull_request && github.event.comment.author_association == 'NONE' }}
name: First issue reply
runs-on: ubuntu-latest
# For some reason, with only issue:write perms the action fails even though that's all we're doing
permissions: write-all
steps:
- name: Checkout main repository
uses: actions/checkout@v5
- name: Check for existing bot comments
id: check-comments
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
BOT_COMMENT_EXISTS=$(gh issue view "$ISSUE_NUMBER" --json comments --jq '.comments[].body' | grep -q "Hi @$USERNAME," && echo "true" || echo "false")
echo "bot_comment_exists=$BOT_COMMENT_EXISTS" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USERNAME: ${{ github.event.comment.user.login }}
- name: First issue reply
if: env.bot_comment_exists == 'false'
run: |
gh issue comment "$ISSUE" --body "Hi @$USERNAME,"$'\n\n'"$(cat .github/FIRST_ISSUE_REPLY.md)"
env:
ISSUE: ${{ github.event.issue.number }}
USERNAME: ${{ github.event.comment.user.login }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}