-
-
Notifications
You must be signed in to change notification settings - Fork 128
80 lines (66 loc) · 3.09 KB
/
pr_greetings.yml
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
name: PR Greetings
on:
pull_request:
types: [opened]
pull_request_target:
types: [opened]
jobs:
greeting:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Check if the PR creator is the repo owner or Weblate
id: check_owner
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_AUTHOR=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
REPO_OWNER=$(jq -r '.repository.owner.login' "$GITHUB_EVENT_PATH")
if [ "$PR_AUTHOR" = "$REPO_OWNER" ] || [ "$PR_AUTHOR" = "weblate" ]; then
echo "The PR creator is the repository owner or Weblate. Skipping greeting message."
echo "skip=true" >> $GITHUB_ENV
else
echo "The PR creator is not the repository owner or Weblate. Checking for previous PRs..."
# Check for both open and closed pull requests by the author
OPEN_PRS=$(gh pr list --author "$PR_AUTHOR" --state open --json number --jq '. | length')
CLOSED_PRS=$(gh pr list --author "$PR_AUTHOR" --state closed --json number --jq '. | length')
TOTAL_PRS=$((OPEN_PRS + CLOSED_PRS))
echo "User $PR_AUTHOR has created $TOTAL_PRS pull request(s) in total"
echo "Open PRs: $OPEN_PRS"
echo "Closed PRs: $CLOSED_PRS"
if [ "$TOTAL_PRS" -eq 1 ]; then
echo "This is the user's first pull request. Sending greeting message."
echo "skip=false" >> $GITHUB_ENV
else
echo "User has previous pull requests. Skipping greeting message."
echo "skip=true" >> $GITHUB_ENV
fi
fi
- name: Send Greeting Message
if: env.skip != 'true'
uses: actions/github-script@v6
with:
script: |
const prNumber = context.payload.pull_request.number;
const message = `
**🎉 Thank you for your contribution!**
Your Pull Request has been successfully submitted and is now awaiting review. We truly appreciate your efforts to improve Dantotsu.
**👥 Connect with the Community**
While you're here, why not join our communities to stay engaged?
- **[Discord](https://discord.com/invite/4HPZ5nAWwM)**: Chat with fellow developers, ask questions, and get the latest updates.
- **[Telegram](https://t.me/dantotsuapp)**: Connect directly with us for real-time discussions and updates.
**📋 What to Expect Next**
- Our team will review your pull request as soon as possible.
- You'll receive notifications if further information or changes are needed.
- Once approved, your changes will be merged into the main project.
We're excited to collaborate with you. Stay tuned for updates!
`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: message
});