-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (77 loc) · 3.12 KB
/
Copy pathissue-welcome.yml
File metadata and controls
80 lines (77 loc) · 3.12 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Called from product repos on issues: opened and pull_request_target: opened.
# pull_request_target is required so fork PRs get the comment; this workflow
# does not check out PR code.
# Edit the comment here; every caller picks it up from main.
name: Welcome
on:
workflow_call:
permissions:
contents: read
issues: write
pull-requests: write
jobs:
comment:
if: >
(
github.event_name == 'issues' &&
github.event.issue.state == 'open' &&
github.event.issue.pull_request == null &&
github.event.issue.user.type != 'Bot' &&
!contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.issue.author_association)
) || (
contains(fromJSON('["pull_request","pull_request_target"]'), github.event_name) &&
github.event.pull_request.state == 'open' &&
github.event.pull_request.user.type != 'Bot' &&
!contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)
)
runs-on: ubuntu-latest
timeout-minutes: 5
concurrency:
group: welcome-${{ github.repository }}-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: false
steps:
- uses: actions/github-script@v7
with:
script: |
const marker = '<!-- vocahq-welcome -->';
const item = context.payload.issue || context.payload.pull_request;
const isPr =
context.eventName === 'pull_request' ||
context.eventName === 'pull_request_target';
const login = item.user.login;
const number = item.number;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
per_page: 100,
});
if (
comments.some(
(c) =>
c.body &&
(c.body.includes(marker) ||
c.body.includes('<!-- vocahq-issue-welcome -->')),
)
) {
return;
}
const thanks = isPr
? `Thanks @${login}. A maintainer will review it.`
: `Thanks @${login}. A maintainer will look into it.`;
const body = [
marker,
thanks,
'',
'---',
'',
'<img src="https://raw.githubusercontent.com/VocaHQ/.github/main/brand/vocahq/voca-logo-512.png" width="22" height="22" align="absmiddle"> **Meanwhile, connect with us:**',
'',
'[](https://discord.gg/t6muquAJbm) [](https://x.com/vocahq)',
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
body,
});