-
Notifications
You must be signed in to change notification settings - Fork 22
66 lines (56 loc) · 1.94 KB
/
Copy pathpr_review_notice.yml
File metadata and controls
66 lines (56 loc) · 1.94 KB
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
name: pr_review_notice
on:
pull_request_target:
types: [opened, reopened]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
comment_review_notice:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
# Use the built-in token so the comment is authored by github-actions[bot]
github-token: ${{ github.token }}
script: |
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
const pr_number = pr.number;
const pr_author = pr.user.login;
const maintainers = ["o2sa"].map(u => u.toLowerCase());
if (maintainers.includes(pr_author.toLowerCase())) return;
const body =
"Thank you for the pull request! ✅\n\n" +
"A maintainer will review this soon. Please be patient while we take a look. 🙌";
// Avoid duplicate comment spam
const { data: comments } = await github.rest.issues.listComments({
owner,
repo,
issue_number: pr_number,
per_page: 100,
});
const already = comments.some(c =>
(c.body || "").includes("Thank you for the pull request! ✅")
);
if (already) return;
// Create comment
await github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body,
});
// React to the PR with 👀
try {
await github.rest.reactions.createForIssue({
owner,
repo,
issue_number: pr_number,
content: "eyes",
});
} catch (e) {
// Don't fail the workflow if reactions aren't permitted
core.info(`Could not add reaction: ${e.message}`);
}