-
Notifications
You must be signed in to change notification settings - Fork 22
60 lines (53 loc) · 2.04 KB
/
gh-issue-notify.yml
File metadata and controls
60 lines (53 loc) · 2.04 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
name: Notify Slack for wizard issues
on:
issues:
types: [opened]
jobs:
notify:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: read
repository-projects: read
steps:
- name: Check issue and build payload
id: check
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
script: |
const issue = context.payload.issue;
// Check if the issue belongs to integration autonomy
const EXCLUDED_PROJECTS = ['Integration autonomy'];
const { node } = await github.graphql(`
query($issueId: ID!) {
node(id: $issueId) {
... on Issue {
projectItems(first: 10) {
nodes {
project { title }
}
}
}
}
}
`, { issueId: issue.node_id });
const projects = (node?.projectItems?.nodes || []).map(n => n.project.title);
const isExcluded = projects.some(p => EXCLUDED_PROJECTS.includes(p));
if (isExcluded) {
core.info(`Skipping: issue belongs to excluded project (${projects.join(', ')})`);
core.setOutput('notify', 'false');
return;
}
const labels = (issue.labels || []).map(l => l.name).join(', ');
const payload = {
text: `New wizard issue: <${issue.html_url}|${issue.title}>\nBy: ${issue.user.login}\nLabels: ${labels || 'none'}`
};
core.setOutput('notify', 'true');
core.setOutput('payload', JSON.stringify(payload));
- name: Notify Slack
if: steps.check.outputs.notify == 'true'
uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
with:
webhook: ${{ secrets.SLACK_WEBHOOK_WIZARD_CHANNEL }}
webhook-type: incoming-webhook
payload: ${{ steps.check.outputs.payload }}