Skip to content

Commit

Permalink
Read webook url from env var
Browse files Browse the repository at this point in the history
  • Loading branch information
polm-stability committed Oct 10, 2023
1 parent 85586fb commit 42491ae
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@

import requests
import json
import os

# This URL is tied to a single channel. That can be generalized, or you can
# create a new "app" to use another channel.
WEBHOOK = (
"https://hooks.slack.com/services/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"
)

WEBHOOK = os.environ.get("WEBHOOK_URL")
if WEBHOOK is None:
print("Webhook URL not found in WEBHOOK_URL env var. Will just print messages.")

def notify(message):
headers = {"Content-Type": "application/json"}
data = json.dumps({"text": message})
requests.post(WEBHOOK, data=data, headers=headers)
if WEBHOOK is None:
print(message)
else:
requests.post(WEBHOOK, data=data, headers=headers)



if __name__ == "__main__":
Expand Down

0 comments on commit 42491ae

Please sign in to comment.