mirror of
https://github.com/dawidd6/action-send-mail.git
synced 2024-12-26 19:13:06 +07:00
init
This commit is contained in:
parent
5e251a5fdf
commit
cca8b03288
27
.github/workflows/test.yml
vendored
Normal file
27
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: Test action
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
branch: [test]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Send mail
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
server_address: ${{secrets.ADDRESS}}
|
||||||
|
server_port: 465
|
||||||
|
username: ${{secrets.USERNAME}}
|
||||||
|
password: ${{secrets.PASSWORD}}
|
||||||
|
subject: ${{github.repository}}
|
||||||
|
body: Test of action completed successfully!
|
||||||
|
to: ${{secrets.USERNAME}}
|
||||||
|
from: github-actions
|
@ -1,7 +1,5 @@
|
|||||||
FROM alpine:3.10
|
FROM ruby:2.6-alpine
|
||||||
|
|
||||||
COPY LICENSE README.md /
|
COPY entrypoint.rb /
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
ENTRYPOINT ["/entrypoint.rb"]
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
|
20
README.md
20
README.md
@ -1,5 +1,19 @@
|
|||||||
# Container Action Template
|
# Send mail Github Action
|
||||||
|
|
||||||
To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/).
|
An action that simply sends a mail to multiple recipients.
|
||||||
|
|
||||||
For info on how to build your first Container action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/container-action.md).
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Send mail
|
||||||
|
uses: dawidd6/action-send-mail@master
|
||||||
|
with:
|
||||||
|
server_address: smtp.gmail.com
|
||||||
|
server_port: 465
|
||||||
|
username: ${{secrets.MAIL_USERNAME}}
|
||||||
|
password: ${{secrets.MAIL_PASSWORD}}
|
||||||
|
subject: Github Actions job result
|
||||||
|
body: Build job of ${{github.repository}} completed successfully!
|
||||||
|
to: obiwan@tatooine.com,yoda@dagobah.com
|
||||||
|
from: Luke Skywalker
|
||||||
|
```
|
||||||
|
42
action.yml
42
action.yml
@ -1,12 +1,34 @@
|
|||||||
name: 'Container Action Template'
|
name: Send mail
|
||||||
description: 'Get started with Container actions'
|
description: Send mail to multiple recipients
|
||||||
author: 'GitHub'
|
author: dawidd6
|
||||||
|
branding:
|
||||||
|
icon: mail
|
||||||
|
color: blue
|
||||||
inputs:
|
inputs:
|
||||||
myInput:
|
server_address:
|
||||||
description: 'Input to use'
|
description: SMTP server address
|
||||||
default: 'world'
|
required: true
|
||||||
|
server_port:
|
||||||
|
description: SMTP server port
|
||||||
|
required: true
|
||||||
|
username:
|
||||||
|
description: Authenticate as this user to SMTP server
|
||||||
|
required: true
|
||||||
|
password:
|
||||||
|
description: Authenticate with this password to SMTP server
|
||||||
|
required: true
|
||||||
|
subject:
|
||||||
|
description: Subject of mail message
|
||||||
|
required: true
|
||||||
|
body:
|
||||||
|
description: Body of mail message
|
||||||
|
required: true
|
||||||
|
to:
|
||||||
|
description: Recipients mail addresses (separated with comma)
|
||||||
|
required: true
|
||||||
|
from:
|
||||||
|
description: Full name of mail sender
|
||||||
|
required: true
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: docker
|
||||||
image: 'Dockerfile'
|
image: Dockerfile
|
||||||
args:
|
|
||||||
- ${{ inputs.myInput }}
|
|
33
entrypoint.rb
Executable file
33
entrypoint.rb
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/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
|
@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh -l
|
|
||||||
|
|
||||||
echo "hello $1"
|
|
Loading…
Reference in New Issue
Block a user