-
Notifications
You must be signed in to change notification settings - Fork 9
42 lines (36 loc) · 2.04 KB
/
contributor_response.yml
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
39
40
41
42
# Runs on new comments and prints a welcome message if the commenter is not a bot,
# is not an existing contributor, and has not already gotten a reply
name: Community Contributor Response
run-name: Auto-response to Community Contributor Comments
on:
issue_comment:
types: [created] # Ensure it only triggers on comment creation
jobs:
auto-response:
runs-on: ubuntu-latest
steps:
- name: Check if commenter is a contributor
id: check-if-commenter-is-a-contributor
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const commenter = context.payload.comment.user.login;
const bots = ['dependabot[bot]', 'renovate[bot]', 'codecov', 'graphite'];
const isBot = bots.includes(commenter);
// Check if the commenter is a contributor
const contributors = await github.rest.repos.listContributors({ owner, repo });
const isContributor = contributors.data.some(contributor => contributor.login === commenter);
// Check if the commenter has already received a response on this issue
const comments = await github.rest.issues.listComments({ owner, repo, issue_number });
const hasReceivedResponse = comments.data.some(comment => comment.user.login === 'github-actions[bot]' && comment.body.includes(commenter));
const shouldComment = !isBot && !isContributor && !hasReceivedResponse;
if (shouldComment) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Thanks, @${commenter}, for your interest in contributing to CiviForm! You can find info on how to get started here: https://github.com/civiform/civiform/wiki/Technical-contribution-guide#community-contributors-not-part-of-exygy-google-or-a-civic-entity.`
});
}