[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / .github / workflows / llvm-bugs.yml
blob36c967e4617cd92e346dd57b7bfc619638b8ecaa
1 name: LLVM Bugs notifier
3 on:
4   issues:
5     types:
6       - opened
8 jobs:
9   auto-subscribe:
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.LLVM_BUGS_KEY }}
20         with:
21           script: |
22             const Mailgun = require('mailgun.js');
23             const formData = require('form-data');
25             const mailgun = new Mailgun(formData);
26             const DOMAIN = 'email.llvm.org';
28             const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
30             github.rest.issues.get({
31               issue_number: context.issue.number,
32               owner: context.repo.owner,
33               repo: context.repo.repo
34             })
35             .then((issue) => {
36               const payload = {
37                 author : issue.data.user.login,
38                 issue  : issue.data.number,
39                 title  : issue.data.title,
40                 url    : issue.data.html_url,
41                 labels : issue.data.labels.map((label) => label.name),
42                 assignee : issue.data.assignees.map((assignee) => assignee.login),
43                 body   : issue.data.body
44               };
46               const data = {
47                 from: 'LLVM Bugs <llvm-bugs@email.llvm.org>',
48                 to: 'llvm-bugs@lists.llvm.org',
49                 subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
50                 template: 'new-github-issue',
51                 'o:tracking-clicks': 'no',
52                 'h:X-Mailgun-Variables': JSON.stringify(payload)
53               };
55               return mg.messages.create(DOMAIN, data);
56             })
57             .then((msg) => console.log(msg));