Skip to content

Commit 8758fe6

Browse files
committed
Workflow to notify/Greet first time PR commenters
1 parent da2ca5b commit 8758fe6

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Greet new commenters
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
8+
env:
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
PR_NUMBER: ${{ github.event.issue.number }}
11+
12+
jobs:
13+
triage:
14+
permissions:
15+
pull-requests: write
16+
if: ${{ github.event.issue.pull_request }}
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Check if user has any existing PR comments in this repository
21+
id: pr-comment-check
22+
run: |
23+
commenter="${{ github.event.comment.user.login }}"
24+
echo "Debug: Checking comment counts for... $commenter"
25+
comment_count=$(gh search prs --owner=CleverRaven --repo=Cataclysm-DDA --commenter $commenter --json id | jq 'length')
26+
27+
echo "Debug: $commenter with $comment_count total comments, including checked comment."
28+
echo "comment_count=$comment_count" >> $GITHUB_OUTPUT
29+
30+
- name: Greet commenters with no previous comments
31+
if: steps.pr-check.outputs.comment_count == 1
32+
run: |
33+
# I have no earthly idea how to pass the commenter on from the previous run (I have tried), so let's just re-acquire it.
34+
commenter_name="${{ github.event.comment.user.login }}"
35+
# We 'hardcode' the URLs here because doing a dynamic url points to OWNER/REPO/pull/code_of_conduct.md. Why is the 'pull' there? No idea.
36+
gh pr comment $PR_NUMBER --body "Hi @$commenter_name, welcome to CleverRaven! We see that this is your first time commenting here. Check out [how development works](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/doc/development_process.md) and be sure to follow the [code of conduct](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/CODE_OF_CONDUCT.md)! We hope to see you around!"

0 commit comments

Comments
 (0)