mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2025-07-02 21:23:15 +07:00
Resolve attachments via glob
This commit is contained in:
9
main.js
9
main.js
@ -1,5 +1,6 @@
|
||||
const nodemailer = require("nodemailer")
|
||||
const core = require("@actions/core")
|
||||
const glob = require("@actions/glob")
|
||||
const fs = require("fs")
|
||||
const showdown = require("showdown")
|
||||
|
||||
@ -29,6 +30,12 @@ function getFrom(from, username) {
|
||||
return `"${from}" <${username}>`
|
||||
}
|
||||
|
||||
async function getAttachments(attachments) {
|
||||
const globber = await glob.create(attachments.split(',').join('\n'))
|
||||
const files = await globber.glob()
|
||||
return files.map(f => ({ path: f }))
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const serverAddress = core.getInput("server_address", { required: true })
|
||||
@ -75,8 +82,8 @@ async function main() {
|
||||
replyTo: replyTo ? replyTo : undefined,
|
||||
text: body ? getBody(body, false) : undefined,
|
||||
html: htmlBody ? getBody(htmlBody, convertMarkdown) : undefined,
|
||||
attachments: attachments ? attachments.split(',').map(f => ({ path: f.trim() })) : undefined,
|
||||
priority: priority ? priority : undefined,
|
||||
attachments: attachments ? getAttachments(attachments) : undefined,
|
||||
})
|
||||
} catch (error) {
|
||||
core.setFailed(error.message)
|
||||
|
Reference in New Issue
Block a user