Add possibility to attach a file to mail

This commit is contained in:
Roman Isko 2020-04-07 09:46:19 +03:00
parent 67e2095a53
commit d4b4fe8144
2 changed files with 7 additions and 0 deletions

View File

@ -33,6 +33,9 @@ inputs:
description: Content-Type HTTP header (text/html or text/plain) description: Content-Type HTTP header (text/html or text/plain)
required: false required: false
default: text/plain default: text/plain
attach_file:
description: File path that will be added to mail message attachments
required: false
runs: runs:
using: node12 using: node12
main: main.js main: main.js

View File

@ -30,6 +30,7 @@ async function main() {
const to = core.getInput("to", { required: true }) const to = core.getInput("to", { required: true })
const from = core.getInput("from", { required: true }) const from = core.getInput("from", { required: true })
const content_type = core.getInput("content_type", { required: true }) const content_type = core.getInput("content_type", { required: true })
const attach_file = core.getInput("attach_file", { required: false })
const transport = nodemailer.createTransport({ const transport = nodemailer.createTransport({
host: server_address, host: server_address,
@ -47,6 +48,9 @@ async function main() {
subject: subject, subject: subject,
text: content_type != "text/html" ? get_body(body) : undefined, text: content_type != "text/html" ? get_body(body) : undefined,
html: content_type == "text/html" ? get_body(body) : undefined, html: content_type == "text/html" ? get_body(body) : undefined,
attachments: {
path: attach_file
}
}) })
console.log(info) console.log(info)