-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: r3drun3 <[email protected]>
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# SEND MAIL REPORT WITH PATCHED IMAGES | ||
|
||
import smtplib | ||
from email.mime.text import MIMEText | ||
from email.mime.multipart import MIMEMultipart | ||
import os | ||
|
||
# Get patched image information from GitHub Actions context | ||
patched_images_str = os.environ.get('PATCHED_IMAGES', '') | ||
patched_images = patched_images_str.split(',') | ||
print("Pathed images: ", patched_images) | ||
|
||
# Prepare the email content | ||
subject = 'Patched Image Report' | ||
body = f'Patched Images:\n\n{", ".join(patched_images)}' | ||
|
||
# Get email and password from GitHub secrets | ||
email_address = os.environ.get('EMAIL_ADDRESS', '') | ||
print("Email address:", email_address) | ||
email_password = os.environ.get('EMAIL_PASSWORD', '') | ||
|
||
# Get email recipients from GitHub secret | ||
recipients = os.environ.get('EMAIL_RECIPIENTS', '').split(',') | ||
print("Recipients:", recipients) | ||
|
||
# Prepare the email message | ||
message = MIMEMultipart() | ||
message['From'] = email_address | ||
message['To'] = ', '.join(recipients) | ||
message['Subject'] = subject | ||
message.attach(MIMEText(body, 'plain')) | ||
|
||
# Connect to the SMTP server and send the email | ||
with smtplib.SMTP('smtp.gmail.com', 587) as server: | ||
server.starttls() | ||
server.login(email_address, email_password) | ||
server.send_message(message) | ||
|
||
print('Email sent successfully!') |