Skip to content

Commit 32be886

Browse files
PR-comment workflow (#45)
* added-prcomment-workflow * workflow * improved * improved * improved-workflow * improved-workflow * improved-workflow * improved-workflow * improved-workflow * improved-workflow * permissions removed * permissions added
1 parent 4a4e5af commit 32be886

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Comment on First-Time Contributor PR
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
pull-requests: write
8+
issues: write
9+
10+
jobs:
11+
first-pr-comment:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check if contributor has merged PRs before
16+
id: check
17+
uses: actions/github-script@v7
18+
with:
19+
script: |
20+
const owner = context.repo.owner;
21+
const repo = context.repo.repo;
22+
const author = context.payload.pull_request.user.login;
23+
24+
const { data } = await github.rest.search.issuesAndPullRequests({
25+
q: `repo:${owner}/${repo} is:pr is:merged author:${author}`
26+
});
27+
28+
core.setOutput("merged_count", data.total_count);
29+
30+
- name: Comment on first PR
31+
if: steps.check.outputs.merged_count == '0'
32+
uses: actions/github-script@v7
33+
with:
34+
script: |
35+
await github.rest.issues.createComment({
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
issue_number: context.payload.pull_request.number,
39+
body: `Thank you for your first contribution! We appreciate your effort and look forward to more contributions in the future.`
40+
});

0 commit comments

Comments
 (0)