]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blob - modules/role/files/cryptoportfolio/slack-notify.py
Add notification for app deployment
[perso/Immae/Projets/Puppet.git] / modules / role / files / cryptoportfolio / slack-notify.py
1 #!/usr/bin/env python3
2
3 import sys
4 import json
5 import urllib3
6
7 project = sys.argv[1]
8 url = sys.argv[2]
9 version = sys.argv[3]
10
11 def post(url, data):
12 urllib3.disable_warnings()
13 http = urllib3.PoolManager()
14
15 encoded = data.encode('utf-8')
16
17 r = http.request("POST", url,
18 headers={'Content-Type': 'application/json'},
19 body=encoded)
20
21 data = {
22 "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png",
23 "text": "Deployed {} on {}".format(version, project),
24 }
25
26 json_data = json.dumps(data)
27 post(url, json_data)