Skip to content

Commit

Permalink
require file:// prefix in body if loading a file
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidd6 committed Dec 8, 2019
1 parent ae69498 commit 2f26726
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
body:
- README.md
- file://README.md
- Test of action completed successfully!
steps:
- name: Checkout
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected],[email protected]
from: Luke Skywalker
```
8 changes: 7 additions & 1 deletion main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
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
Expand Down

0 comments on commit 2f26726

Please sign in to comment.