Skip to content

Commit

Permalink
Create discord_webhook.py
Browse files Browse the repository at this point in the history
  • Loading branch information
afreakyelf authored Apr 3, 2024
1 parent 20a89be commit 2106e00
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions discord_webhook.py
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()

0 comments on commit 2106e00

Please sign in to comment.