Skip to content

Commit 0d7e409

Browse files
committed
Created slack notification GitHub Action
1 parent c23350b commit 0d7e409

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Issue Status Notification
2+
3+
on:
4+
schedule:
5+
- cron: '0 8 * * 1' # Runs at 9 AM CET (8 AM UTC) on Mondays
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-issues:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Get Issues Status
13+
id: get-issues
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
// Get current date and date 2 weeks ago
18+
const now = new Date();
19+
const twoWeeksAgo = new Date();
20+
twoWeeksAgo.setDate(twoWeeksAgo.getDate() - 14);
21+
22+
// Get awaiting-triage issues
23+
const triageIssues = await github.rest.issues.listForRepo({
24+
owner: context.repo.owner,
25+
repo: context.repo.name,
26+
labels: 'stat:awaiting-triage',
27+
state: 'open'
28+
});
29+
30+
// Get reply-needed issues
31+
const replyNeededIssues = await github.rest.issues.listForRepo({
32+
owner: context.repo.owner,
33+
repo: context.repo.name,
34+
labels: 'stat:reply-needed',
35+
state: 'open'
36+
});
37+
38+
// Filter reply-needed issues older than 2 weeks
39+
const staleReplyNeeded = replyNeededIssues.data.filter(issue => {
40+
const labelDate = new Date(issue.labels.find(l => l.name === 'stat:reply-needed').created_at);
41+
return labelDate < twoWeeksAgo;
42+
});
43+
44+
// Format messages
45+
const triageList = triageIssues.data.map(issue =>
46+
`• ${issue.title} (${issue.html_url})`
47+
).join('\n');
48+
49+
const replyNeededList = staleReplyNeeded.map(issue =>
50+
`• ${issue.title} - Label added on ${new Date(issue.labels.find(l => l.name === 'stat:reply-needed').created_at).toLocaleDateString()} (${issue.html_url})`
51+
).join('\n');
52+
53+
core.setOutput('triageCount', triageIssues.data.length);
54+
core.setOutput('replyNeededCount', staleReplyNeeded.length);
55+
core.setOutput('triageList', triageList);
56+
core.setOutput('replyNeededList', replyNeededList);
57+
58+
- name: Send Slack Notification
59+
if: steps.get-issues.outputs.triageCount > 0 || steps.get-issues.outputs.replyNeededCount > 0
60+
uses: slackapi/[email protected]
61+
with:
62+
channel-id: 'C083Y0FUWBF'
63+
payload: |
64+
{
65+
"blocks": [
66+
{
67+
"type": "header",
68+
"text": {
69+
"type": "plain_text",
70+
"text": "📊 NGO GitHub Issue Status Report"
71+
}
72+
},
73+
{
74+
"type": "section",
75+
"text": {
76+
"type": "mrkdwn",
77+
"text": "*Awaiting Triage Issues (${{ steps.get-issues.outputs.triageCount }}):*\n${{ steps.get-issues.outputs.triageList }}"
78+
}
79+
},
80+
{
81+
"type": "divider"
82+
},
83+
{
84+
"type": "section",
85+
"text": {
86+
"type": "mrkdwn",
87+
"text": "*Stale Reply Needed Issues (${{ steps.get-issues.outputs.replyNeededCount }}):*\n${{ steps.get-issues.outputs.replyNeededList }}"
88+
}
89+
}
90+
]
91+
}
92+
env:
93+
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

0 commit comments

Comments
 (0)