-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20a89be
commit 2106e00
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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').replace('\n', '\\n') # Preserving newlines | ||
release_url = os.getenv('RELEASE_URL') | ||
|
||
# Construct the message content with Markdown | ||
content = f"**New Release: {release_tag}**\\n\\n{release_body}\\n\\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() |