diff options
author | Anton Korobeynikov <anton@korobeynikov.info> | 2021-12-17 00:25:55 +0300 |
---|---|---|
committer | Anton Korobeynikov <anton@korobeynikov.info> | 2021-12-17 00:26:21 +0300 |
commit | 25285577874f642a6ec648c942e07d6ae2d77c1b (patch) | |
tree | 29cb020dcedb8c284d54f66174649e1b8a188798 /.github | |
parent | 8a85be807bd453eb9c88d0126c75fd5ea393f60d (diff) |
Install test mailer for github bugs
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/llvm-bugs.yml | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/.github/workflows/llvm-bugs.yml b/.github/workflows/llvm-bugs.yml new file mode 100644 index 000000000000..701e3068759c --- /dev/null +++ b/.github/workflows/llvm-bugs.yml @@ -0,0 +1,57 @@ +name: LLVM Bugs notifier + +on: + issues: + types: + - opened + +jobs: + auto-subscribe: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: 14 + - run: npm install mailgun.js form-data + - name: Send notification + uses: actions/github-script@v5 + 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(function(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 => { return label.name }), + assignee : issue.data.assignees.map(assignee => { return assignee.login }), + body : issue.data.body + }; + + const data = { + from: "LLVM Bugs <llvm-bugs@email.llvm.org>", + to: "anton.korobeynikov@llvm.org", + subject: `[Bug ${issue.data.number}] ${issue.data.title}`, + template: "new-github-issue", + 'h:X-Mailgun-Variables': JSON.stringify(payload) + }; + + return mg.messages.create(DOMAIN, data) + }) + .then(msg => console.log(msg)); |