-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·99 lines (85 loc) · 3.45 KB
/
Copy pathreport-mailer.yml
File metadata and controls
executable file
·99 lines (85 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# CTO Watchdog — Report Mailer v1.1.0
# Sends audit reports via email on workflow completion
# Part of: cto-watchdog — Dhaher Labs
# Author: Mulky Malikul Dhaher
name: CTO Report — Email Notification
on:
workflow_run:
workflows: ['CTO Watch — Event Monitor', 'CTO Audit — Weekly Comprehensive']
types: [completed]
workflow_dispatch:
inputs:
recipient:
description: 'Email recipient'
required: false
default: 'dhaher-labs@email.com'
subject:
description: 'Email subject'
required: false
default: 'CTO Watchdog Report'
permissions:
contents: read
actions: read
env:
CTO_WATCHDOG_VERSION: '1.1.0'
jobs:
send-report:
name: Send Email Report
runs-on: ubuntu-latest
if: always()
steps:
- name: Download audit artifacts
uses: actions/download-artifact@v4
continue-on-error: true
- name: Prepare report
id: prepare
run: |
# Determine recipient based on repository owner
OWNER="${{ github.event.repository.owner.login || 'dhaher-labs' }}"
if [ "$OWNER" = "mulkymalikuldhaher" ]; then
echo "recipient=mulkymalikuldhr@mail.com" >> $GITHUB_OUTPUT
else
echo "recipient=dhaher-labs@email.com" >> $GITHUB_OUTPUT
fi
# Prepare subject
WORKFLOW="${{ github.event.workflow_run.name || 'CTO Watchdog' }}"
CONCLUSION="${{ github.event.workflow_run.conclusion || 'completed' }}"
# Add emoji for conclusion status
if [ "$CONCLUSION" = "success" ]; then
STATUS="✅ SUCCESS"
elif [ "$CONCLUSION" = "failure" ]; then
STATUS="❌ FAILED"
else
STATUS="ℹ️ $CONCLUSION"
fi
echo "subject=[CTO-Watchdog] $STATUS — $WORKFLOW" >> $GITHUB_OUTPUT
# Build report body
echo "report_body<<EOF" >> $GITHUB_OUTPUT
echo "CTO Watchdog Automated Report" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "Workflow: $WORKFLOW" >> $GITHUB_OUTPUT
echo "Status: $STATUS" >> $GITHUB_OUTPUT
echo "Repository: ${{ github.repository }}" >> $GITHUB_OUTPUT
echo "Trigger: ${{ github.event_name }}" >> $GITHUB_OUTPUT
echo "Run: ${{ github.event.workflow_run.html_url || github.server_url }}/${{ github.repository }}/actions" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "This is an automated notification from CTO Watchdog v1.1.0." >> $GITHUB_OUTPUT
echo "---" >> $GITHUB_OUTPUT
echo "Dhaher Labs — Building Intelligent Systems" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Send email
if: ${{ secrets.CTO_WATCHDOG_SMTP_SERVER }}
uses: dawidd6/action-send-mail@v3
with:
server_address: ${{ secrets.CTO_WATCHDOG_SMTP_SERVER }}
server_port: ${{ secrets.CTO_WATCHDOG_SMTP_PORT }}
username: ${{ secrets.CTO_WATCHDOG_SMTP_USER }}
password: ${{ secrets.CTO_WATCHDOG_SMTP_PASS }}
from: ${{ secrets.CTO_WATCHDOG_SMTP_FROM }}
to: ${{ steps.prepare.outputs.recipient }}
subject: ${{ steps.prepare.outputs.subject }}
body: ${{ steps.prepare.outputs.report_body }}
- name: Log notification
run: |
echo "📧 Notification sent to: ${{ steps.prepare.outputs.recipient }}"
echo "📋 Subject: ${{ steps.prepare.outputs.subject }}"