]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame - modules/role/files/cryptoportfolio/slack-notify.py
Upgrade bot
[perso/Immae/Projets/Puppet.git] / modules / role / files / cryptoportfolio / slack-notify.py
CommitLineData
a4c92ff7
IB
1#!/usr/bin/env python3
2
3import sys
4import json
5import urllib3
6
7project = sys.argv[1]
8url = sys.argv[2]
9version = sys.argv[3]
10
11def 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
21data = {
22 "icon_url": "https://learn.puppet.com/static/images/logos/Puppet-Logo-Mark-Amber.png",
23 "text": "Deployed {} on {}".format(version, project),
24 }
25
26json_data = json.dumps(data)
27post(url, json_data)