Skip to content

Commit ac5907e

Browse files
authored
implement auto welcome workflow for PR and Issues
1 parent 40b52d6 commit ac5907e

File tree

1 file changed

+53
-22
lines changed

1 file changed

+53
-22
lines changed

.github/workflows/welcome.yml

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

33
permissions:
44
actions: write
@@ -17,33 +17,64 @@ permissions:
1717
statuses: write
1818

1919
on:
20-
pull_request:
21-
types: [opened, closed]
2220
issues:
23-
types: [opened]
21+
types: [opened, closed]
22+
pull_request_target:
23+
types: [opened, closed]
2424

2525
jobs:
26-
greet_new_contributor:
26+
welcomer:
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: wow-actions/welcome@v1.3.1
29+
- name: Auto Welcome on Issues or PRs
30+
uses: actions/github-script@v6
3031
with:
31-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
FIRST_ISSUE_REACTIONS: "+1, hooray, rocket, heart"
33-
FIRST_ISSUE: >
34-
👋 Greetings @{{ author }}!
35-
36-
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.
37-
38-
FIRST_PR: >
39-
👋 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}`;
4036
41-
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;
4239
43-
FIRST_PR_MERGED: >
44-
🎉 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;
4559
46-
You've just merged your first pull request! We're excited to have you in our community. Keep up the fantastic contributions!
47-
STAR_MESSAGE: If you enjoy this project, please consider ⭐ starring ⭐ our repository!
48-
env:
49-
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)