-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (53 loc) · 1.76 KB
/
hook.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
name: Notify on Commit or PR Merge
on:
push:
branches:
- main
pull_request:
types: [closed, opened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "14"
- name: Install dependencies
run: npm install -g nodemailer
- name: Send email notification
env:
GITHUB_EVENT: ${{ toJson(github.event) }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_USER: ${{ github.event.pusher.name || github.event.pull_request.user.login }}
EVENT_TYPE: ${{ github.event_name }}
EMAIL: ${{ secrets.EMAIL }}
EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }}
run: |
node -e "
const nodemailer = require('nodemailer');
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.EMAIL_PASSWORD
}
});
const mailOptions = {
from: process.env.EMAIL,
to: process.env.EMAIL,
subject: 'GitHub Event Notification',
text: \`Event Type: ${{ github.event_name }}\n
GitHub Event: ${{ env.GITHUB_EVENT }}\n
GitHub Actor: ${{ env.GITHUB_ACTOR }}\n
GitHub User: ${{ env.GITHUB_USER }}\`
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Email sent: ' + info.response);
});
"