Skip to content

chore: Slack notification GitHub Action #3400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/slack-notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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/[email protected]
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 }}