Skip to content

Commit 7b47319

Browse files
authored
enhance welcome workflow
1 parent a5a97ef commit 7b47319

File tree

1 file changed

+62
-22
lines changed

1 file changed

+62
-22
lines changed

.github/workflows/welcome.yml

Lines changed: 62 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,80 @@
1-
name: New Contributor Welcome
1+
name: Welcome Comments
22

33
permissions:
44
actions: write
5+
attestations: write
56
checks: write
67
contents: write
8+
deployments: write
9+
id-token: write
710
issues: write
11+
discussions: write
12+
packages: write
13+
pages: write
814
pull-requests: write
15+
repository-projects: write
16+
security-events: write
17+
statuses: write
918

1019
on:
11-
pull_request:
12-
types: [opened, closed]
1320
issues:
14-
types: [opened]
21+
types: [opened, closed]
22+
pull_request_target:
23+
types: [opened, closed]
1524

1625
jobs:
17-
greet_new_contributor:
26+
welcomer:
1827
runs-on: ubuntu-latest
1928
steps:
20-
- uses: bubkoo/welcome-action@v1
29+
- name: Auto Welcome on Issues or PRs
30+
uses: actions/github-script@v6
2131
with:
22-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
FIRST_ISSUE_REACTIONS: "+1, hooray, rocket, heart"
24-
FIRST_ISSUE: >
25-
👋 Greetings @{{ author }}!
26-
27-
We're thrilled to see you opening your first issue! Your input is invaluable to us. Don’t forget to adhere to our issue template for the best experience.
28-
29-
FIRST_PR: >
30-
👋 Welcome aboard, @{{ author }}!
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
script: |
34+
const author = context.payload.sender.login;
35+
const commentBody = (message) => `👋 @${author} 👋\n\n${message}`;
3136
32-
We're delighted to have your first pull request! Please take a moment to check our contributing guidelines to ensure a smooth process.
37+
if (context.eventName === 'issues') {
38+
const issue = context.payload.issue;
3339
34-
FIRST_PR_MERGED: >
35-
🎉 Kudos @{{ author }}!
40+
if (context.payload.action === 'opened') {
41+
const message = `We're thrilled to see you opening an issue! Your input is valuable to us. Don’t forget to fill out our issue template for the best experience. We will look into it soon.`;
42+
github.rest.issues.createComment({
43+
issue_number: issue.number,
44+
owner: context.repo.owner,
45+
repo: context.repo.repo,
46+
body: commentBody(message),
47+
});
48+
} else if (context.payload.action === 'closed') {
49+
const message = `Thanks for closing the issue! We appreciate your updates.`;
50+
github.rest.issues.createComment({
51+
issue_number: issue.number,
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
body: commentBody(message),
55+
});
56+
}
57+
} else if (context.eventName === 'pull_request_target') {
58+
const pr = context.payload.pull_request;
3659
37-
You've just merged your first pull request! We're excited to have you in our community. Keep up the fantastic contributions!
38-
STAR_MESSAGE: If you enjoy this project, please consider ⭐ starring ⭐ this repository!
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
if (context.payload.action === 'opened') {
61+
const message = `We're delighted to have your pull request! Please take a moment to check our contributing guidelines and ensure you've filled out the PR template for a smooth process. We will review it soon.`;
62+
github.rest.issues.createComment({
63+
issue_number: pr.number,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: commentBody(message),
67+
});
68+
} else if (context.payload.action === 'closed') {
69+
const message = pr.merged
70+
? `🎉 You've just merged your pull request! We're excited to have you in our community. Keep up the fantastic contributions to the project!`
71+
: `Thanks for closing the pull request! Your contributions are valuable to us.`;
72+
73+
github.rest.issues.createComment({
74+
issue_number: pr.number,
75+
owner: context.repo.owner,
76+
repo: context.repo.repo,
77+
body: commentBody(message),
78+
});
79+
}
80+
}

0 commit comments

Comments
 (0)