require file:// prefix in body if loading a file

This commit is contained in:
Dawid Dziurla 2019-12-08 11:23:04 +01:00
parent ae69498bf4
commit 2f26726c4f
No known key found for this signature in database
GPG Key ID: 7B6D8368172E9B0B
3 changed files with 10 additions and 4 deletions

View File

@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
body:
- README.md
- file://README.md
- Test of action completed successfully!
steps:
- name: Checkout

View File

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

View File

@ -14,7 +14,13 @@ to = ENV['INPUT_TO']
from = ENV['INPUT_FROM']
# Body
body = File.exist?(body) ? File.read(body) : 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