Skip to content

Commit 461656f

Browse files
committed
updated email format
1 parent 1807d38 commit 461656f

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

β€Žget_email_webhook.pyβ€Ž

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,34 @@ def github_webhook():
102102

103103
if event == "repository" and data.get("action") in ["created", "deleted"]:
104104
repo = data["repository"]
105-
repo_name = repo["full_name"]
106-
action = data["action"]
107-
default_branch = repo.get("default_branch", "N/A")
105+
repo_name = repo["name"]
106+
visibility = repo.get("private", False)
107+
visibility_icon = "πŸ”’ Private" if visibility else "🌐 Public"
108108
owner = repo["owner"]["login"]
109+
default_branch = repo.get("default_branch", "N/A")
109110
creator = data["sender"]["login"]
110111
created_at = repo.get("created_at")
112+
updated_at = repo.get("updated_at")
113+
url = repo.get("html_url", "")
114+
115+
# Remove T and Z
111116
if created_at:
112-
# Remove T and Z
113117
created_at = created_at.replace("T", " ").replace("Z", "")
118+
if updated_at:
119+
updated_at = updated_at.replace("T", " ").replace("Z", "")
114120

115-
subject = f"[GitHub Alert] Repository {action}: {repo_name}"
121+
subject = f"[GitHub Alert] Repository {data['action']}: {repo_name}"
116122
body = (
117-
f"A repository was {action} in your GitHub organization.\n\n"
118-
f"Repository: {repo_name}\n"
119-
f"Owner: {owner}\n"
120-
f"Default branch: {default_branch}\n"
121-
f"Action by: {creator}\n"
123+
f"πŸ“Œ Repository Name: {repo_name}\n"
124+
f"{visibility_icon}\n"
125+
f"πŸ‘€ Owner: {owner}\n"
126+
f"🌿 Default Branch: {default_branch}\n"
127+
f"πŸ•’ Created at: {created_at}\n"
128+
f"πŸ•’ Last updated: {updated_at}\n"
129+
f"🌍 URL: {url}\n"
130+
f"πŸ‘€ Action by: {creator}\n\n"
131+
f"Full payload:\n{json.dumps(data, indent=2)}"
122132
)
123-
if created_at:
124-
body += f"Created at: {created_at}\n"
125-
body += f"\nFull payload:\n{json.dumps(data, indent=2)}"
126133

127134
print(f"πŸ“© Sending email alert: {subject}")
128135
send_email_via_graph(subject, body)

0 commit comments

Comments
Β (0)