Skip to content

Commit a69bf49

Browse files
ci: add automated thank you workflow for merged PRs
Signed-off-by: Shivansh Sahu <sahushivansh142@gmail.com>
1 parent ad30e43 commit a69bf49

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/thank-you.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Contributor Thank You
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
permissions:
9+
pull-requests: write
10+
11+
jobs:
12+
thank-you:
13+
# Only run if the PR was actually merged (not just closed without merging)
14+
if: github.event.pull_request.merged == true
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Leave a Thank You Comment
18+
uses: actions/github-script@v7
19+
with:
20+
script: |
21+
const creator = context.payload.pull_request.user.login;
22+
23+
// Skip bots to avoid comment loops
24+
if (creator.endsWith('[bot]')) {
25+
console.log('Skipping bot account.');
26+
return;
27+
}
28+
29+
// Search for previous merged PRs by this user in this repo
30+
const query = `repo:${context.repo.owner}/${context.repo.repo} type:pr is:merged author:${creator}`;
31+
const result = await github.rest.search.issuesAndPullRequests({ q: query });
32+
const mergedCount = result.data.total_count;
33+
34+
let message = '';
35+
36+
// If count is 1, this current PR is their very first merged PR!
37+
if (mergedCount === 1) {
38+
message = `### 🎉 Congratulations on your first merged Pull Request, @${creator}! \n\nWelcome to the **PipeCD** community! We are absolutely thrilled to have you here. Thank you for taking the time to contribute to the project.\n\nWe hope this is the first of many! 🚀\n\n*(If you haven't already, feel free to join our [Community Slack/Discord](#) to say hi!)*`;
39+
} else {
40+
// Returning contributor
41+
message = `### Awesome work, @${creator}! 🎉\n\nThank you for another great contribution to PipeCD! Your continued support and dedication help make this project better for everyone. 🙌`;
42+
}
43+
44+
// Post the comment to the PR
45+
await github.rest.issues.createComment({
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: context.payload.pull_request.number,
49+
body: message
50+
});

0 commit comments

Comments
 (0)