I tried to post to ChatWork when deploying using python's deploy tool fabric.
fabric.py
from fabric.api import run,cd,sudo,env
env.use_ssh_config=True
def chatwork_notification():
env.chatwork_token = your token
env.chatwork_roomid = your room id
with cd("%s" % env.deploy_target_dir):
git_log = run('git -p log --oneline ORIG_HEAD.. | cat')
run('curl -X POST -H "X-ChatWorkToken: %s" -d "body=[hr]deploy complete\n%s [hr]" "https://api.chatwork.com/v1/rooms/%s/messages"' %(env.chatwork_token, git_log, env.chatwork_roomid))
def production():
env.hosts = your host
env.deploy_target_dir = your dir
def deploy():
with cd("%s" % env.deploy_target_dir):
sudo("git pull)
chatwork_notification()
It's almost like this.
Execution looks like this
fab production deploy
This will automatically send the most recently deployed commit ^^
Recommended Posts