.github/scripts: include commit body, cut pointless title, repo
diff --git a/.github/scripts/discord_notify.py b/.github/scripts/discord_notify.py
index ca46567..b73b5d2 100755
--- a/.github/scripts/discord_notify.py
+++ b/.github/scripts/discord_notify.py
@@ -11,11 +11,11 @@
if not os.environ.get('GITHUB_SHA'):
print("Error: GITHUB_SHA environment variable is required")
sys.exit(1)
-
+
if not os.environ.get('GITHUB_REPOSITORY'):
print("Error: GITHUB_REPOSITORY environment variable is required")
sys.exit(1)
-
+
if not os.environ.get('DISCORD_WEBHOOK_FOR_COMMITS'):
print("Error: DISCORD_WEBHOOK_FOR_COMMITS environment variable is required")
sys.exit(1)
@@ -28,14 +28,20 @@
['git', 'log', '-1', '--pretty=format:%s'],
text=True, stderr=subprocess.DEVNULL
).strip()
-
+
+ # Get commit body (description)
+ commit_body = subprocess.check_output(
+ ['git', 'log', '-1', '--pretty=format:%b'],
+ text=True, stderr=subprocess.DEVNULL
+ ).strip()
+
# Get commit author
commit_author = subprocess.check_output(
['git', 'log', '-1', '--pretty=format:%an'],
text=True, stderr=subprocess.DEVNULL
).strip()
-
- return commit_message, commit_author
+
+ return commit_message, commit_body, commit_author
except subprocess.CalledProcessError as e:
print(f"Failed to get commit information: {e}")
sys.exit(1)
@@ -43,28 +49,28 @@
def main():
# Validate we're running in the correct environment
validate_environment()
-
+
# Check for test mode
if os.environ.get('DISCORD_TEST_MODE') == '1':
print("Running in test mode - will not send actual webhook")
-
+
# Get commit information from git
- commit_message, commit_author = get_commit_info()
-
+ commit_message, commit_body, commit_author = get_commit_info()
+
# Get remaining info from environment
github_sha = os.environ.get('GITHUB_SHA')
commit_sha = github_sha[:8]
commit_url = f"https://github.com/{os.environ.get('GITHUB_REPOSITORY')}/commit/{github_sha}"
-
+
# Create timestamp
timestamp = datetime.now(timezone.utc).strftime('%Y-%m-%dT%H:%M:%S.%fZ')[:-3] + 'Z'
-
+
# Create Discord webhook payload
payload = {
"embeds": [
{
- "title": "New commit to main",
- "description": f"**{commit_message}**",
+ "title": commit_message,
+ "description": commit_body,
"color": 5814783,
"fields": [
{
@@ -77,30 +83,25 @@
"value": f"[{commit_sha}]({commit_url})",
"inline": True
},
- {
- "name": "Repository",
- "value": os.environ.get('GITHUB_REPOSITORY'),
- "inline": True
- }
],
"timestamp": timestamp
}
]
}
-
+
# Convert to JSON
json_payload = json.dumps(payload)
-
+
# Test mode - just print the payload
if os.environ.get('DISCORD_TEST_MODE') == '1':
print("Generated Discord payload:")
print(json.dumps(payload, indent=2))
print("✓ Test mode: payload generated successfully")
return
-
+
# Send to Discord webhook
webhook_url = os.environ.get('DISCORD_WEBHOOK_FOR_COMMITS')
-
+
req = urllib.request.Request(
webhook_url,
data=json_payload.encode('utf-8'),
@@ -109,7 +110,7 @@
'User-Agent': 'sketch.dev developers'
}
)
-
+
try:
with urllib.request.urlopen(req) as response:
if response.status == 204: