forked from Ikalus1988/MisakaNet
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (44 loc) · 1.69 KB
/
Copy pathstar-request.yml
File metadata and controls
49 lines (44 loc) · 1.69 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
name: Star Request
on:
pull_request:
types: [opened]
pull_request_review:
types: [submitted]
jobs:
star-request:
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'pull_request_review' &&
github.event.review.state == 'approved')
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: read
steps:
- name: Post star request comment
continue-on-error: true
uses: actions/github-script@v9
with:
script: |
const body = github.event_name === 'pull_request'
? '🎉 Thank you for opening this PR! If you find MisakaNet helpful, please consider leaving a ⭐ Star on the repository. It means a lot to our community and helps us review contributions faster!'
: '🎉 Thank you for the review! If you find MisakaNet helpful, please consider leaving a ⭐ Star on the repository. It helps us grow!';
// Check if we already commented (avoid spam)
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100,
});
const alreadyCommented = comments.data.some(c =>
c.user.login === 'github-actions[bot]' &&
c.body.includes('⭐ Star')
);
if (!alreadyCommented) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}