-
Notifications
You must be signed in to change notification settings - Fork 1.2k
90 lines (74 loc) · 3.38 KB
/
auto-comment.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: 💬 Auto Comment
on:
issues:
types: [opened]
pull_request:
types: [opened, closed]
permissions:
issues: write
pull-requests: write
jobs:
auto_comment:
runs-on: ubuntu-latest
steps:
- name: 🤖 Auto Comment on Issues and PRs
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const author = context.payload.sender.login;
try {
if (context.eventName === 'issues' && context.payload.action === 'opened') {
const issue = await github.rest.issues.get({
owner,
repo,
issue_number: context.issue.number
});
const isFeatureRequest = issue.data.title.toLowerCase().includes('feat');
let commentBody;
if (isFeatureRequest) {
commentBody = `Hey @${author}! 👋 Thanks for your feature request! 💡
We love hearing new ideas from our community. Here's what happens next:
1. 📋 Our team will review your suggestion
2. 💬 We might reach out for more details if needed
3. 🔍 We'll evaluate how it fits with our roadmap
4. 📢 We'll update you on the status
Thanks for helping make reNgine even better! 🚀`;
} else {
commentBody = `Hey @${author}! 👋 Thanks for flagging this! 🐛🐞
Before we dig in, Let's make sure you have:
🔍 Gone through the documentation: https://rengine.wiki
🕵️ Make sure it's not a known issue
📝 Provided us all the details related to this bug`;
}
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: commentBody
});
} else if (context.eventName === 'pull_request' && context.payload.action === 'opened') {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: `Woohoo @${author}! 🎉 You've just dropped some hot new code! 🔥
Hang tight while we review this! You rock! 🤘`
});
} else if (context.eventName === 'pull_request' && context.payload.action === 'closed') {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner,
repo,
body: `Holy smokes, @${author}! 🤯 You've just made reNgine even more awesome!
Your code is now part of the reNgine hall of fame. 🏆
Keep the cool ideas coming - maybe next time you'll break the internet! 💻💥
Virtual high fives all around! 🙌`
});
}
console.log('Comment created successfully');
} catch (error) {
console.error('Error creating comment:', error);
core.setFailed(`Action failed with error: ${error}`);
}