Skip to content
Draft
Show file tree
Hide file tree
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
81 changes: 81 additions & 0 deletions .github/workflows/copilot-issue-slack-notifier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Copilot Issue Slack Notifier

on:
issues:
types: [opened]

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Check for copilot keyword and notify Slack
uses: actions/github-script@v7
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
script: |
const title = context.payload.issue.title || '';
const body = context.payload.issue.body || '';
const combined = `${title} ${body}`;

if (!/\bcopilot\b/i.test(combined)) {
core.info('No "copilot" keyword found in issue title or body. Skipping notification.');
return;
}

const issue = context.payload.issue;
const repo = context.payload.repository;

const payload = {
channel: '#support-squad-copilot-shiftlog',
text: 'Review release and assign SME',
attachments: [
{
color: '#0366d6',
fields: [
{ title: 'Repository', value: repo.full_name, short: true },
{ title: 'Author', value: issue.user.login, short: true },
{ title: 'Issue', value: `<${issue.html_url}|${issue.title}>`, short: false }
]
}
]
};

const webhookUrl = process.env.SLACK_WEBHOOK_URL;
if (!webhookUrl) {
core.setFailed('SLACK_WEBHOOK_URL secret is not set.');
return;
}

const https = require('https');
const data = JSON.stringify(payload);
const url = new URL(webhookUrl);

await new Promise((resolve, reject) => {
const req = https.request(
{
hostname: url.hostname,
path: url.pathname + url.search,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data)
}
},
(res) => {
let body = '';
res.on('data', (chunk) => { body += chunk; });
res.on('end', () => {
if (res.statusCode >= 200 && res.statusCode < 300) {
core.info(`Slack notification sent successfully (HTTP ${res.statusCode}).`);
resolve();
} else {
reject(new Error(`Slack webhook returned HTTP ${res.statusCode}: ${body}`));
}
});
}
);
req.on('error', reject);
req.write(data);
req.end();
});
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# release-assets
This repository is used to manage assets related to releases in github/releases

## Copilot Issue Slack Notifier

The workflow at `.github/workflows/copilot-issue-slack-notifier.yml` automatically sends a Slack notification to **`#support-squad-copilot-shiftlog`** whenever a new issue is opened in this repository that mentions the word **`copilot`** (case-insensitive, whole-word match) in its title or body.

### How it works

1. Triggers on the `issues.opened` event.
2. Checks the issue title and body for the whole word `copilot` (e.g. matches *"Copilot bug"* but not *"github-copilots"*).
3. If matched, POSTs a Slack message containing:
- The fixed text `Review release and assign SME`
- Issue title (as a link), author login, and repository name
4. If no match is found, the workflow exits silently — no notification is sent.
5. An empty or missing issue body is handled safely (treated as an empty string).

### Secret configuration

Add the following secret to this repository before the workflow can send notifications:

| Secret name | Description |
|---------------------|--------------------------------------------------------------|
| `SLACK_WEBHOOK_URL` | Incoming Webhook URL for the `#support-squad-copilot-shiftlog` Slack channel |

To add the secret: **Repository Settings → Secrets and variables → Actions → New repository secret**.

### Quick test plan

| Scenario | Issue title | Issue body | Expected result |
|----------|-------------|------------|-----------------|
| Match in title | `Copilot is slow today` | *(any)* | Slack notification sent |
| Match in body | `Performance issue` | `Need copilot assistance` | Slack notification sent |
| Case-insensitive match | `COPILOT integration` | *(any)* | Slack notification sent |
| No match | `Release checklist` | `Deploy new version` | No notification (silent skip) |
| Partial word — no match | `github-copilot` | *(empty)* | No notification (whole-word only) |
| Empty body | `Copilot question` | *(empty/null)* | Slack notification sent (title matched) |