send-email #1444
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: send-email | |
on: | |
workflow_dispatch: | |
inputs: | |
subject: | |
description: Email subject | |
required: true | |
body: | |
description: Email body | |
required: true | |
jobs: | |
send-email: | |
runs-on: ubuntu-latest | |
name: Send email | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Read and set email environment | |
run: | | |
# mask subject and body | |
export SUBJECT=$(jq -r '.inputs.subject' $GITHUB_EVENT_PATH) | |
echo "subject=$SUBJECT" >> $GITHUB_ENV; echo "::add-mask::$SUBJECT" | |
export BODY=$(echo "$(jq -r '.inputs.body' $GITHUB_EVENT_PATH)" > body.txt; base64 body.txt -w 0) | |
echo "body=$BODY" >> $GITHUB_ENV; echo "::add-mask::$BODY" | |
# set and mask variables from mail environment file | |
export $(echo "$EMAIL_ENV") | |
echo "mail_to=$MAIL_TO" >> $GITHUB_ENV; echo "::add-mask::$MAIL_TO" | |
echo "mail_name=$MAIL_NAME" >> $GITHUB_ENV; echo "::add-mask::$MAIL_NAME" | |
echo "mail_alias=$MAIL_ALIAS" >> $GITHUB_ENV; echo "::add-mask::$MAIL_ALIAS" | |
echo "mail_pass=$MAIL_PASS" >> $GITHUB_ENV; echo "::add-mask::$MAIL_PASS" | |
echo "smtp_server=$SMTP_SERVER" >> $GITHUB_ENV; echo "::add-mask::$SMTP_SERVER" | |
echo "smtp_port=$SMTP_PORT" >> $GITHUB_ENV; echo "::add-mask::$SMTP_PORT" | |
shell: bash | |
env: | |
EMAIL_ENV: ${{ secrets.email_env_jprs }} | |
- name: Send email | |
uses: ./actions/send-email | |
with: | |
subject: ${{ env.subject }} | |
body: ${{ env.body }} | |
to: ${{ env.mail_to }} | |
from: ${{ env.mail_name }} | |
from_alias: ${{ env.mail_alias }} | |
mail_pass: ${{ env.mail_pass }} | |
smtp_server: ${{ env.smtp_server }} | |
smtp_port: ${{ env.smtp_port }} |