Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import httplib, json
import getopt, sys, os
import subprocess
def get_data_from_git(format_string, commit):
return subprocess.check_output(['git', 'log', '-1', '--format=format:%s' % format_string, commit])
def get_author(commit):
return get_data_from_git('%an', commit)
def post_message(connection, url, app):
headers = {'Content-Type': 'application/json'}
commit = os.environ['COMMIT']
version = os.environ['HEROKU_V']
color = 'good'
text = '%s deployed version %s of <| #%s>' % ( get_author(commit), version, app, app)
message = {
'username': 'Shippable',
'fallback': text,
'pretext': text,
'color': color
connection.request('POST', url, json.dumps(message), headers)
response = connection.getresponse()
def main():
opts, args = getopt.getopt(sys.argv[1:], ':sf', ['app=', 'swh='])
except getopt.GetoptError as err:
print str(err)
app = None
url = None
message = None
for o, arg in opts:
if o == '--app':
app = arg
elif o == '--swh':
url = arg
connection = httplib.HTTPSConnection('')
post_message(connection, url, app)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.