6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

fabricとChatWorkApiでデプロイ時に自動でChatWorkに投稿するようにしてみた

Posted at

pythonのデプロイツール fabricを使ってデプロイした際にChatWorkに投稿するようにしてみました。

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()

だいたいこんな感じ。

実行はこんな感じ

fab production deploy

これで直近デプロイされたコミットが自動で送られてくる^^

チャットワーク api

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?