Skip to content

Commit 9263c86

Browse files
authored
notify new-bugs-announce on new issue open (#32421)
1 parent defbbd6 commit 9263c86

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: new-bugs-announce notifier
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
8+
jobs:
9+
notify-new-bugs-announce:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: 14
15+
- run: npm install mailgun.js form-data
16+
- name: Send notification
17+
uses: actions/github-script@v5
18+
env:
19+
MAILGUN_API_KEY: ${{ secrets.PSF_MAILGUN_KEY }}
20+
with:
21+
script: |
22+
const Mailgun = require("mailgun.js");
23+
const formData = require('form-data');
24+
const mailgun = new Mailgun(formData);
25+
const DOMAIN = "mg.python.org";
26+
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
27+
github.rest.issues.get({
28+
issue_number: context.issue.number,
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
})
32+
.then(function(issue) {
33+
const payload = {
34+
author : issue.data.user.login,
35+
issue : issue.data.number,
36+
title : issue.data.title,
37+
url : issue.data.html_url,
38+
labels : issue.data.labels.map(label => { return label.name }).join(", "),
39+
assignee : issue.data.assignees.map(assignee => { return assignee.login }),
40+
body : issue.data.body
41+
};
42+
43+
const data = {
44+
from: "CPython Issues <[email protected]>",
45+
46+
subject: `[Issue ${issue.data.number}] ${issue.data.title}`,
47+
template: "new-github-issue",
48+
'o:tracking-clicks': 'no',
49+
'h:X-Mailgun-Variables': JSON.stringify(payload)
50+
};
51+
return mg.messages.create(DOMAIN, data)
52+
})
53+
.then(msg => console.log(msg));

0 commit comments

Comments
 (0)