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
+43-17Lines changed: 43 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -3,8 +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 the job can run in the base-repo context and comment/label PRs from forks.
7
-
#WARNING: Do NOT check out or run untrusted PR code in this job when using pull_request_target.
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
8
pull_request_target:
9
9
types: [opened, reopened]
10
10
@@ -15,45 +15,54 @@ permissions:
15
15
jobs:
16
16
auto-comment:
17
17
runs-on: ubuntu-latest
18
-
19
18
steps:
20
19
- name: 🧠 Auto Comment
21
20
uses: actions/github-script@v7
22
21
with:
23
22
github-token: ${{ secrets.GITHUB_TOKEN }}
24
23
script: |
25
-
// Prefer checking payload properties rather than exact eventName string,
26
-
// so this works for both pull_request and pull_request_target events.
27
24
const repo = context.repo;
28
25
29
-
// ISSUE opened/reopened
26
+
// Issue opened/reopened
30
27
if (context.payload.issue) {
31
-
const user = context.payload.issue.user?.login || 'contributor';
32
-
const message = `👋 Hi @${user}!\n\nThanks for opening an issue in **MyCMD**.\n\nWe’ll review it soon — meanwhile, please ensure logs and reproduction steps are clear.
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.`;
34
32
35
33
await github.rest.issues.createComment({
36
34
owner: repo.owner,
37
35
repo: repo.repo,
38
-
issue_number: context.payload.issue.number,
36
+
issue_number: issueNumber,
39
37
body: message
40
38
});
41
39
42
-
// add a reaction if desired (make sure permissions include issues: write)
43
40
await github.rest.reactions.createForIssue({
44
41
owner: repo.owner,
45
42
repo: repo.repo,
46
-
issue_number: context.payload.issue.number,
43
+
issue_number: issueNumber,
47
44
content: "tada"
48
45
});
49
46
47
+
try {
48
+
await github.rest.issues.addLabels({
49
+
owner: repo.owner,
50
+
repo: repo.repo,
51
+
issue_number: issueNumber,
52
+
labels: ["triage", "needs-info"]
53
+
});
54
+
} catch (err) {
55
+
core && core.info && core.info("Could not add labels to issue: " + err.message);
56
+
}
57
+
50
58
return;
51
59
}
52
60
53
-
// PULL REQUEST opened/reopened
61
+
// Pull request opened/reopened (or synchronized)
54
62
if (context.payload.pull_request) {
55
-
const user = context.payload.pull_request.user?.login || 'contributor';
0 commit comments