-
-
Notifications
You must be signed in to change notification settings - Fork 240
Expand file tree
/
Copy pathdiscord_webhook.py
More file actions
26 lines (20 loc) · 723 Bytes
/
discord_webhook.py
File metadata and controls
26 lines (20 loc) · 723 Bytes
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
# discord_webhook.py
import json
import os
import requests
def main():
webhook_url = os.getenv('DISCORD_WEBHOOK_URL')
release_tag = os.getenv('RELEASE_TAG')
release_body = os.getenv('RELEASE_BODY')
release_url = os.getenv('RELEASE_URL')
# Construct the message content with Markdown
content = f"Hello @everyone, new release **{release_tag}** is out 🚀 \n{release_body} \n[View Release]({release_url})"
# Prepare the webhook payload
payload = {
"content": content
}
# Send the webhook
response = requests.post(webhook_url, json=payload)
response.raise_for_status() # This will raise an error if the request fails
if __name__ == "__main__":
main()