Skip to content

Commit 42ee1ac

Browse files
authored
feat(workflows): add first-time contributor welcome workflow and fix script loading (#378)
* fix: Fixed linting issues * feat(workflows): add contributor welcome workflow and fix script loading
1 parent 0dd15fe commit 42ee1ac

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

.github/scripts/welcomeScript.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module.exports = async ({ github, context }) => {
2+
const owner = context.repo.owner;
3+
const repo = context.repo.repo;
4+
const issueNumber = context.issue.number;
5+
const eventName = context.eventName;
6+
const ghUsername = context.payload.sender.login;
7+
8+
try {
9+
const issueAssociation =
10+
context.payload.issue?.author_association;
11+
12+
if (
13+
eventName === 'issues' &&
14+
issueAssociation === 'FIRST_TIMER'
15+
) {
16+
return await github.rest.issues.createComment({
17+
owner,
18+
repo,
19+
issue_number: issueNumber,
20+
body: `👋 Thanks for opening your first issue, @${ghUsername}!
21+
22+
We appreciate your contribution and are excited to have you here. Please make sure to follow the contribution guidelines and provide as much detail as possible.
23+
24+
To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community:
25+
https://discord.gg/QueQN83wn
26+
27+
Looking forward to collaborating with you!`
28+
});
29+
}
30+
31+
const prAssociation =
32+
context.payload.pull_request?.author_association;
33+
34+
if (
35+
eventName === 'pull_request_target' &&
36+
(
37+
prAssociation === 'FIRST_TIMER' ||
38+
prAssociation === 'FIRST_TIME_CONTRIBUTOR'
39+
)
40+
) {
41+
return await github.rest.issues.createComment({
42+
owner,
43+
repo,
44+
issue_number: issueNumber,
45+
body: `🎉 Thanks for your first contribution, @${ghUsername}!
46+
47+
We're excited to have you here. A maintainer will review your PR soon. Please check CI results and review any feedback if needed.
48+
49+
To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community:
50+
https://discord.gg/QueQN83wn
51+
52+
Looking forward to collaborating with you!`
53+
});
54+
}
55+
56+
} catch (error) {
57+
console.error(error);
58+
}
59+
};

.github/workflows/unassign-unlinked-issues.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
issues: write
1313

1414
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
17+
1518
- name: Unassign issues with no linked PR and notify
1619
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 #v9.0.0
1720
with:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Welcome First-Time Contributors
2+
3+
on:
4+
issues:
5+
types: [opened]
6+
pull_request_target:
7+
types: [opened]
8+
9+
permissions:
10+
issues: write
11+
pull-requests: write
12+
13+
jobs:
14+
welcome:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2
20+
21+
- name: Welcome first-time contributor
22+
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
script: |
26+
const script = require('./.github/scripts/welcomeScript.js');
27+
await script({ github, context });

0 commit comments

Comments
 (0)