Skip to content

Commit 50c4770

Browse files
authored
Merge branch 'king04aman:main' into main
2 parents e66bc45 + ac5907e commit 50c4770

File tree

1 file changed

+65
-24
lines changed

1 file changed

+65
-24
lines changed

.github/workflows/welcome.yml

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

33
permissions:
4-
issues: write
5-
pull-requests: write
64
actions: write
5+
attestations: write
6+
checks: write
77
contents: write
8+
deployments: write
9+
id-token: write
10+
issues: write
11+
discussions: write
12+
packages: write
13+
pages: write
14+
pull-requests: write
15+
repository-projects: write
16+
security-events: write
17+
statuses: write
818

919
on:
10-
pull_request:
11-
types: [opened, closed]
1220
issues:
13-
types: [opened]
21+
types: [opened, closed]
22+
pull_request_target:
23+
types: [opened, closed]
1424

1525
jobs:
16-
greet_new_contributor:
26+
welcomer:
1727
runs-on: ubuntu-latest
1828
steps:
19-
- uses: wow-actions/welcome@v1.3.1
29+
- name: Auto Welcome on Issues or PRs
30+
uses: actions/github-script@v6
2031
with:
21-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22-
FIRST_ISSUE_REACTIONS: "+1, hooray, rocket, heart"
23-
FIRST_ISSUE: >
24-
👋 Greetings @{{ author }}!
25-
26-
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.
27-
28-
FIRST_PR: >
29-
👋 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}`;
3036
31-
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;
3239
33-
FIRST_PR_MERGED: >
34-
🎉 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;
3559
36-
You've just merged your first pull request! We're excited to have you in our community. Keep up the fantastic contributions!
37-
STAR_MESSAGE: If you enjoy this project, please consider ⭐ starring ⭐ our repository!
38-
env:
39-
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)