Skip to content

Send_Automated_Email #33

Send_Automated_Email

Send_Automated_Email #33

name: Send_Automated_Email
on:
workflow_run:
workflows: ["Generate_RespiCast_Forecasts"] # Trigger when this workflow finishes
types:
- completed
# Or you can manually trigger the workflow
workflow_dispatch:
jobs:
send_email_job:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository to access the files
- name: Checkout repository
uses: actions/checkout@v3
# Step 1a: Print debug information for Gmail credentials
- name: Print Gmail credentials (for debugging)
run: |
echo "Username: ${{ secrets.GMAIL_EMAIL }}"
echo "Password (first 3 characters): $(echo '${{ secrets.GMAIL_APP_PASSWORD }}' | cut -c1-3)***"
- name: Check if secrets are available
run: |
if [[ -z "${{ secrets.GMAIL_EMAIL }}" ]]; then
echo "GMAIL_EMAIL secret is not set!"
else
echo "GMAIL_EMAIL secret is set!"
fi
# Step 2: Prepare the email content and attach files
- name: Send email via gmail
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com # gmail SMTP server
#server_port: 587 # Port for TLS
server_port: 443 # Port for TLS
#username: ${{ secrets.GMAIL_EMAIL }}
username: [email protected]
password: ${{ secrets.GMAIL_APP_PASSWORD }}
subject: RespiCast Forecast Workflow Completed
body: Test test
to: [email protected] # Replace with the recipient's email address
#from: ${{ secrets.GMAIL_EMAIL }}
from: [email protected]
secure: true
attachments: |
./Forecasting-hubs_models/model_output/figures/2024-12-04-ECDC-soca_simplex_ILI.jpg
./Forecasting-hubs_models/model_output/figures/2024-12-04-ECDC-soca_simplex_ARI.jpg
./Forecasting-hubs_models/model_output/figures/2024-12-04-ECDC-soca_simplex_hosp.jpg