-
Notifications
You must be signed in to change notification settings - Fork 459
100 lines (89 loc) · 3.85 KB
/
slack-notification.yml
File metadata and controls
100 lines (89 loc) · 3.85 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# GitHub Action that aims to collect information and notifies our Slack channel about:
# 1) Any new issue (with stat:awaiting-triage label)
# 2) Issues we should reply to that are not addressed for 1+ weeks (stat:reply-needed label)
# Some useful information about implementation are placed under https://github.com/integrations/slack
# Notification will be sent at 9 AM CET on Mondays as part of our Bug Triage process
name: Issue Status Notification
on:
schedule:
- cron: '0 8 * * 1' # Runs at 9 AM CET (8 AM UTC) on Mondays
workflow_dispatch:
jobs:
check-issues:
runs-on: ubuntu-latest
steps:
- name: Get Issues Status
id: get-issues
uses: actions/github-script@v7
with:
script: |
// Get current date and date 2 weeks ago
const now = new Date();
const twoWeeksAgo = new Date();
twoWeeksAgo.setDate(twoWeeksAgo.getDate() - 14);
// Get awaiting-triage issues
const triageIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.name,
labels: 'stat:awaiting-triage',
state: 'open'
});
// Get reply-needed issues
const replyNeededIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.name,
labels: 'stat:reply-needed',
state: 'open'
});
// Filter reply-needed issues older than 2 weeks
const staleReplyNeeded = replyNeededIssues.data.filter(issue => {
const labelDate = new Date(issue.labels.find(l => l.name === 'stat:reply-needed').created_at);
return labelDate < twoWeeksAgo;
});
// Format messages
const triageList = triageIssues.data.map(issue =>
`• ${issue.title} (${issue.html_url})`
).join('\n');
const replyNeededList = staleReplyNeeded.map(issue =>
`• ${issue.title} - Label added on ${new Date(issue.labels.find(l => l.name === 'stat:reply-needed').created_at).toLocaleDateString()} (${issue.html_url})`
).join('\n');
core.setOutput('triageCount', triageIssues.data.length);
core.setOutput('replyNeededCount', staleReplyNeeded.length);
core.setOutput('triageList', triageList);
core.setOutput('replyNeededList', replyNeededList);
- name: Send Slack Notification
if: steps.get-issues.outputs.triageCount > 0 || steps.get-issues.outputs.replyNeededCount > 0
uses: slackapi/slack-github-action@v1.26.0
with:
channel-id: 'C083Y0FUWBF'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "📊 NGO GitHub Issue Status Report"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Awaiting Triage Issues (${{ steps.get-issues.outputs.triageCount }}):*\n${{ steps.get-issues.outputs.triageList }}"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Stale Reply Needed Issues (${{ steps.get-issues.outputs.replyNeededCount }}):*\n${{ steps.get-issues.outputs.replyNeededList }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}