forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (55 loc) · 1.94 KB
/
llvm-bugs.yml
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
61
62
63
name: LLVM Bugs notifier
permissions:
contents: read
issues: read
on:
issues:
types:
- opened
jobs:
auto-subscribe:
runs-on: ubuntu-latest
if: github.repository == 'llvm/llvm-project'
steps:
- uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
- run: npm install mailgun.js form-data
- name: Send notification
uses: actions/github-script@v6
env:
MAILGUN_API_KEY: ${{ secrets.LLVM_BUGS_KEY }}
with:
script: |
const Mailgun = require('mailgun.js');
const formData = require('form-data');
const mailgun = new Mailgun(formData);
const DOMAIN = 'email.llvm.org';
const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
})
.then((issue) => {
const payload = {
author : issue.data.user.login,
issue : issue.data.number,
title : issue.data.title,
url : issue.data.html_url,
labels : issue.data.labels.map((label) => label.name),
assignee : issue.data.assignees.map((assignee) => assignee.login),
body : issue.data.body
};
const data = {
from: 'LLVM Bugs <[email protected]>',
to: '[email protected]',
subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
template: 'new-github-issue',
'o:tracking-clicks': 'no',
'h:X-Mailgun-Variables': JSON.stringify(payload)
};
return mg.messages.create(DOMAIN, data);
})
.then((msg) => console.log(msg));