X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Frole%2Ffiles%2Fcryptoportfolio%2Fslack-notify.py;fp=modules%2Frole%2Ffiles%2Fcryptoportfolio%2Fslack-notify.py;h=fe64fb68784fc22df1dc2eef9c8f9ebb12309973;hb=a4c92ff7477d09b480cab028411bc7c6b250604e;hp=0000000000000000000000000000000000000000;hpb=d765eedf28199f6723dee5dab7c81a357be86f72;p=perso%2FImmae%2FProjets%2FPuppet.git diff --git a/modules/role/files/cryptoportfolio/slack-notify.py b/modules/role/files/cryptoportfolio/slack-notify.py new file mode 100644 index 0000000..fe64fb6 --- /dev/null +++ b/modules/role/files/cryptoportfolio/slack-notify.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import sys +import json +import urllib3 + +project = sys.argv[1] +url = sys.argv[2] +version = sys.argv[3] + +def post(url, data): + urllib3.disable_warnings() + http = urllib3.PoolManager() + + encoded = data.encode('utf-8') + + r = http.request("POST", url, + headers={'Content-Type': 'application/json'}, + body=encoded) + +data = { + "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png", + "text": "Deployed {} on {}".format(version, project), + } + +json_data = json.dumps(data) +post(url, json_data)