You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/workflows/auto-reply.yml
+65-44Lines changed: 65 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -3,10 +3,8 @@ name: 🤖 Auto Reply to Issues & PRs
3
3
on:
4
4
issues:
5
5
types: [opened, reopened]
6
-
# Use pull_request_target so this job can write comments/labels on PRs from forks.
7
-
# SECURITY: Do NOT check out or execute untrusted PR code in this workflow.
8
6
pull_request_target:
9
-
types: [opened, reopened]
7
+
types: [opened, reopened, synchronize]
10
8
11
9
permissions:
12
10
issues: write
@@ -23,82 +21,105 @@ jobs:
23
21
script: |
24
22
const repo = context.repo;
25
23
26
-
// Issue opened/reopened
27
-
if (context.payload.issue) {
28
-
const issue = context.payload.issue;
29
-
const user = issue.user?.login || 'contributor';
30
-
const issueNumber = issue.number;
31
-
const message = `👋 Hi @${user}!\n\nThanks for opening an issue in **MyCMD**.\n\nWe’ll review it soon — please ensure reproduction steps and logs are included.`;
32
-
33
-
await github.rest.issues.createComment({
24
+
async function commentExists(issue_number, messageSnippet) {
if (!reactions.data.some(r => r.content === reaction)) {
40
+
await github.rest.reactions.createForIssue({
41
+
owner: repo.owner,
42
+
repo: repo.repo,
43
+
issue_number,
44
+
content: reaction
45
+
});
46
+
}
47
+
}
46
48
49
+
async function addLabels(issue_number, labels) {
47
50
try {
48
51
await github.rest.issues.addLabels({
49
52
owner: repo.owner,
50
53
repo: repo.repo,
51
-
issue_number: issueNumber,
52
-
labels: ["triage", "needs-info"]
54
+
issue_number,
55
+
labels
53
56
});
54
57
} catch (err) {
55
-
core && core.info && core.info("Could not add labels to issue: " + err.message);
58
+
core?.info?.("Could not add labels: " + err.message);
56
59
}
57
-
58
-
return;
59
60
}
60
61
61
-
// Pull request opened/reopened (or synchronized)
62
+
// Handle Pull Requests
62
63
if (context.payload.pull_request) {
63
64
const pr = context.payload.pull_request;
64
65
const user = pr.user?.login || 'contributor';
65
66
const prNumber = pr.number;
66
67
67
-
const message = `🚀 Hi @${user}!\n\nThank you for contributing to **MyCMD**. A maintainer will review your PR shortly. 🎉`;
68
+
const message = `🚀 Hi @${user}!
68
69
69
-
await github.rest.issues.createComment({
70
-
owner: repo.owner,
71
-
repo: repo.repo,
72
-
issue_number: prNumber,
73
-
body: message
74
-
});
70
+
Thank you for contributing to **MyCMD**. A maintainer will review your PR shortly. 🎉
75
71
76
-
await github.rest.reactions.createForIssue({
77
-
owner: repo.owner,
78
-
repo: repo.repo,
79
-
issue_number: prNumber,
80
-
content: "rocket"
81
-
});
72
+
### Thank you for raising this issue!
73
+
We'll review it as soon as possible. We truly appreciate your contributions! ✨ Meanwhile make sure you've visited the README.md, CONTRIBUTING.md, and CODE_OF_CONDUCT.md before creating a PR for this. Also, please do NOT create a PR until this issue has been assigned to you. 😊`;
0 commit comments