llvm-project
63 строки · 1.9 Кб
1name: LLVM Bugs notifier
2
3permissions:
4contents: read
5issues: read
6
7on:
8issues:
9types:
10- opened
11
12jobs:
13auto-subscribe:
14runs-on: ubuntu-latest
15if: github.repository == 'llvm/llvm-project'
16steps:
17- uses: actions/setup-node@v4
18with:
19node-version: 18
20check-latest: true
21- run: npm install mailgun.js form-data
22- name: Send notification
23uses: actions/github-script@v6
24env:
25MAILGUN_API_KEY: ${{ secrets.LLVM_BUGS_KEY }}
26with:
27script: |
28const Mailgun = require('mailgun.js');
29const formData = require('form-data');
30
31const mailgun = new Mailgun(formData);
32const DOMAIN = 'email.llvm.org';
33
34const mg = mailgun.client({ username: 'api', key: process.env.MAILGUN_API_KEY });
35
36github.rest.issues.get({
37issue_number: context.issue.number,
38owner: context.repo.owner,
39repo: context.repo.repo
40})
41.then((issue) => {
42const payload = {
43author : issue.data.user.login,
44issue : issue.data.number,
45title : issue.data.title,
46url : issue.data.html_url,
47labels : issue.data.labels.map((label) => label.name),
48assignee : issue.data.assignees.map((assignee) => assignee.login),
49body : issue.data.body
50};
51
52const data = {
53from: 'LLVM Bugs <llvm-bugs@email.llvm.org>',
54to: 'llvm-bugs@lists.llvm.org',
55subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
56template: 'new-github-issue',
57'o:tracking-clicks': 'no',
58'h:X-Mailgun-Variables': JSON.stringify(payload)
59};
60
61return mg.messages.create(DOMAIN, data);
62})
63.then((msg) => console.log(msg));
64