Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
Signed-off-by: r3drun3 <[email protected]>
  • Loading branch information
R3DRUN3 committed Feb 6, 2024
1 parent 01c92fe commit ae07d65
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions send_mail_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@
# Prepare the HTML content
current_timestamp = datetime.now().strftime('%Y-%m-%d')
subject = 'IMMUNIZE: OCI Images Patching Report'
html_body = f'<h1>Patched Images πŸ’‰ {current_timestamp}</h1><ul>'


html_body += '</ul><br />'
html_body += 'check the full catalog πŸ“š <a href="https://github.com/R3DRUN3?tab=packages&repo_name=immunize">here</a> !'
html_body += '<br /><br />'
html_body += '<h2>Stay Safe! πŸ’ͺ</h2>'
html_body = f'<h1>Patched Images πŸ’‰ {current_timestamp}</h1>'

# Get email and password from GitHub secrets
email_address = os.environ.get('EMAIL_ADDRESS', '')
Expand All @@ -32,16 +26,27 @@
message['From'] = email_address
message['To'] = ', '.join(recipients)
message['Subject'] = subject

# Get all directories with the name "*-openvex-report" in root of the project folder
report_directories = [dirname for dirname in os.listdir(script_directory) if os.path.isdir(os.path.join(script_directory, dirname)) and dirname.endswith("-openvex-report")]

# Iterate through report directories
for report_dir in report_directories:
report_dir_path = os.path.join(script_directory, report_dir)
# Get all files in the report directory
report_files = [filename for filename in os.listdir(report_dir_path) if os.path.isfile(os.path.join(report_dir_path, filename))]
# Attach reports to the email
for report_file in report_files:
with open(os.path.join(report_dir_path, report_file), 'rb') as file:
part = MIMEApplication(file.read(), Name=os.path.basename(report_file))
part['Content-Disposition'] = f'attachment; filename="{report_file}"'
message.attach(part)

html_body += '<br />'
html_body += 'check the full catalog πŸ“š <a href="https://github.com/R3DRUN3?tab=packages&repo_name=immunize">here</a> !'
html_body += '<br /><br />'
html_body += '<h2>Stay Safe! πŸ’ͺ</h2>'
message.attach(MIMEText(html_body, 'html'))
# Get all files named "*-openvex-report" in root of the project folder
report_files = [filename for filename in os.listdir(script_directory) if filename.endswith("-openvex-report")]
# Attach reports to the email
for report_file in report_files:
html_body += f'<li>{report_file}</li>'
with open(os.path.join(script_directory, report_file), 'rb') as file:
part = MIMEApplication(file.read(), Name=os.path.basename(report_file))
part['Content-Disposition'] = f'attachment; filename="{report_file}"'
message.attach(part)

# Connect to the GMAIL SMTP server and send the emails
with smtplib.SMTP('smtp.gmail.com', 587) as server:
Expand Down

0 comments on commit ae07d65

Please sign in to comment.