9 Commits
v1.0.0 ... v1

Author SHA1 Message Date
f16ced8d0e LICENSE: correct holder 2020-03-05 23:26:16 +01:00
b4d21e7654 README: mention content_type 2019-12-17 23:49:39 +01:00
8fee2012a2 new content_type input
allow to set Content-Type HTTP header to a desired value
2019-12-17 23:45:26 +01:00
df3751004c workflow: send mail to pusher too 2019-12-17 23:44:47 +01:00
2f26726c4f require file:// prefix in body if loading a file 2019-12-08 11:23:04 +01:00
ae69498bf4 README: mention latest change 2019-12-06 10:30:05 +01:00
f50066a2fe read body from file if specified so 2019-12-06 10:26:00 +01:00
445b6879ac main: format 2019-12-06 10:18:17 +01:00
6e749a80b9 entrypoint -> main 2019-11-30 20:19:41 +01:00
7 changed files with 64 additions and 40 deletions

View File

@ -8,6 +8,11 @@ on:
jobs: jobs:
main: main:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy:
matrix:
body:
- file://README.md
- Test of action completed successfully!
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -19,6 +24,6 @@ jobs:
username: ${{secrets.USERNAME}} username: ${{secrets.USERNAME}}
password: ${{secrets.PASSWORD}} password: ${{secrets.PASSWORD}}
subject: ${{github.repository}} subject: ${{github.repository}}
body: Test of action completed successfully! body: ${{matrix.body}}
to: ${{secrets.USERNAME}} to: ${{github.event.pusher.email}},${{secrets.USERNAME}}
from: github-actions from: github-actions

View File

@ -1,5 +1,5 @@
FROM ruby:2.6-alpine FROM ruby:2.6-alpine
COPY entrypoint.rb / COPY *.rb /
ENTRYPOINT ["/entrypoint.rb"] ENTRYPOINT ["/main.rb"]

View File

@ -1,7 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2018 GitHub, Inc. and contributors Copyright (c) 2020 Dawid Dziurla
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -13,7 +13,12 @@ An action that simply sends a mail to multiple recipients.
username: ${{secrets.MAIL_USERNAME}} username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}} password: ${{secrets.MAIL_PASSWORD}}
subject: Github Actions job result subject: Github Actions job result
# Literal body:
body: Build job of ${{github.repository}} completed successfully! body: Build job of ${{github.repository}} completed successfully!
# Read file contents as body:
body: file://README.md
to: obiwan@tatooine.com,yoda@dagobah.com to: obiwan@tatooine.com,yoda@dagobah.com
from: Luke Skywalker from: Luke Skywalker
# Optional content type:
content_type: text/html
``` ```

View File

@ -21,7 +21,7 @@ inputs:
description: Subject of mail message description: Subject of mail message
required: true required: true
body: body:
description: Body of mail message description: Body of mail message (might be a filename to read from)
required: true required: true
to: to:
description: Recipients mail addresses (separated with comma) description: Recipients mail addresses (separated with comma)
@ -29,6 +29,10 @@ inputs:
from: from:
description: Full name of mail sender description: Full name of mail sender
required: true required: true
content_type:
description: Content-Type HTTP header (MIME type)
required: false
default: text/plain
runs: runs:
using: docker using: docker
image: Dockerfile image: Dockerfile

View File

@ -1,33 +0,0 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'net/smtp'
# Inputs
address = ENV["INPUT_SERVER_ADDRESS"]
port = ENV["INPUT_SERVER_PORT"]
username = ENV["INPUT_USERNAME"]
password = ENV["INPUT_PASSWORD"]
subject = ENV["INPUT_SUBJECT"]
body = ENV["INPUT_BODY"]
to = ENV["INPUT_TO"]
from = ENV["INPUT_FROM"]
# Message
message = <<EOM
Subject: #{subject}
From: #{from} <#{username}>
#{body}
EOM
# Send
begin
smtp = Net::SMTP.new(address, port.to_i)
smtp.enable_tls
smtp.start(address, username, password, :login)
smtp.send_message(message, username, to.split(","))
rescue StandardError => e
puts "Error: #{e.message}"
exit 1
end

44
main.rb Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'net/smtp'
# Inputs
server_address = ENV['INPUT_SERVER_ADDRESS']
server_port = ENV['INPUT_SERVER_PORT']
username = ENV['INPUT_USERNAME']
password = ENV['INPUT_PASSWORD']
subject = ENV['INPUT_SUBJECT']
body = ENV['INPUT_BODY']
to = ENV['INPUT_TO']
from = ENV['INPUT_FROM']
content_type = ENV['INPUT_CONTENT_TYPE'] || 'text/plain'
# Body
prefix = 'file://'
body = if body.start_with?(prefix)
path = body.delete_prefix(prefix)
File.read(path)
else
body
end
# Message
message = <<~END_OF_MESSAGE
Content-Type: #{content_type}; charset=utf-8
Subject: #{subject}
From: #{from} <#{username}>
#{body}
END_OF_MESSAGE
# Send
begin
smtp = Net::SMTP.new(server_address, server_port.to_i)
smtp.enable_tls
smtp.start(server_address, username, password, :login)
smtp.send_message(message, username, to.split(','))
rescue StandardError => e
puts "Error: #{e.message}"
exit 1
end