-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (79 loc) · 3.02 KB
/
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
81
82
83
84
85
name: Greetings
on: [pull_request_target, issues]
jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
# Greeting for first interaction using actions/first-interaction
- name: First Interaction Greeting
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Welcome to the Lithium! Thanks for giving us a issue."
pr-message: "Welcome to the Lithium! Thanks for giving us a pull request."
# General greeting for every new issue
- name: Greet Every Issue
if: github.event_name == 'issues'
uses: actions/github-script@v6
with:
script: |
const issueComment = `Hello @${{ github.actor }}! Thanks for raising this issue.`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: issueComment
})
# General greeting for every new pull request
- name: Greet Every PR
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v6
with:
script: |
const prComment = `Hello @${{ github.actor }}! Thanks for this PR.`
github.rest.pulls.createReview({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: prComment,
event: 'COMMENT'
})
# Add labels to new issues and PRs
- name: Label New Issues and PRs
uses: actions/github-script@v6
with:
script: |
const labels = ['needs-triage'];
if (context.eventName === 'issues') {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
} else if (context.eventName === 'pull_request_target') {
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labels
})
}
# Auto Assign Reviewers based on the time of day
- name: Auto-assign Reviewers Based on Time of Day
if: github.event_name == 'pull_request_target'
uses: actions/github-script@v6
with:
script: |
const hour = new Date().getHours();
const isDayTime = hour > 8 && hour < 20;
const reviewers = isDayTime ? ['day-reviewer1', 'day-reviewer2'] : ['night-reviewer1', 'night-reviewer2'];
github.rest.pulls.requestReviewers({
pull_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
reviewers: reviewers
})