Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Email subject

Email body

### `attachment`

Filename of the attachment

## Outputs

### `status`
Expand All @@ -36,4 +40,5 @@ with:
to: 'example@example.com'
subject: 'building main'
body: 'This is a notification from GitHub actions.'
attachment: 'artifacts.zip'
```
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ inputs:
description: 'Email subject'
body:
description: 'Email body'
attachment:
description: 'Email attachment'
outputs:
status: # id of output
description: 'The delivery status of the notification'
Expand Down
25 changes: 18 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
const core = require('@actions/core');
const { email } = require('@cinotify/js')
const mime = require('mime');
const { email } = require('@cinotify/js');
const {readFileSync} = require('fs');

try {
const to = core.getInput('to');
const subject = core.getInput('subject');
const body = core.getInput('body');
email({
to,
subject,
body
}).then(() => {
const payload = {to, subject, body};

const attachmentPath = core.getInput('attachment');
if (attachmentPath) {
const file = readFileSync(attachmentPath);
const attachment = {
filename: attachmentPath,
type: mime.getType(attachmentPath),
content: file.toString('base64')
}
payload.attachments = [attachment];
}

email(payload).then(() => {
core.setOutput("status", "ok")
}).catch(err => {
core.setFailed(err.message)
})
} catch (error) {
core.setFailed(error.message);
}
}
1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions node_modules/@cinotify/js/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions node_modules/@cinotify/js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions node_modules/@cinotify/js/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading