[PYTHON] I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api

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 ^^

Chatwork api

Recommended Posts

I tried to automatically post to ChatWork at the time of deployment with fabric and ChatWork Api
I tried to touch the API of ebay
I tried to get the authentication code of Qiita API with Python.
I tried to automatically extract the movements of PES players with software
I tried to get the movie information of TMDb API with Python
I tried to read and save automatically with VOICEROID2 2
I tried to automatically read and save with VOICEROID2
I tried to uncover our darkness with Chatwork API
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to notify the update of "Become a novelist" using "IFTTT" and "Become a novelist API"
I tried to automate the article update of Livedoor blog with Python and selenium.
I just wanted to extract the data of the desired date and time with Django
I tried to compare the processing speed with dplyr of R and pandas of Python
I tried to find the average of the sequence with TensorFlow
I tried to illustrate the time and time in C language
I tried to display the time and today's weather w
I tried the same data analysis with kaggle notebook (python) and Power BI at the same time ②
How to write offline real time I tried to solve the problem of F02 with Python
I tried to move ROS (Melodic) with the first Raspberry Pi (Stretch) at the beginning of 2021
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I tried the same data analysis with kaggle notebook (python) and Power BI at the same time ①
I tried to describe the traffic in real time with WebSocket
I tried standalone deployment of play with fabric [AWS operation with boto] [Play deployment]
I tried to automate the watering of the planter with Raspberry Pi
I tried to expand the size of the logical volume with LVM
I tried to improve the efficiency of daily work with Python
I tried to automatically collect images of Kanna Hashimoto with Python! !!
I tried to touch the COTOHA API
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 1
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 2
I tried to visualize the age group and rate distribution of Atcoder
zoom I tried to quantify the degree of excitement of the story at the meeting
I tried to express sadness and joy with the stable marriage problem.
I tried to learn the angle from sin and cos with chainer
I tried to extract and illustrate the stage of the story using COTOHA
I tried to verify and analyze the acceleration of Python by Cython
I tried to analyze the negativeness of Nono Morikubo. [Compare with Posipa]
I tried to streamline the standard role of new employees with Python
I tried to visualize the text of the novel "Weathering with You" with WordCloud
I tried to get the RSS of the top song of the iTunes store automatically
I tried to predict the behavior of the new coronavirus with the SEIR model.
I tried to control the network bandwidth and delay with the tc command
I tried to take the difference of Config before and after work with pyATS / Genie self-made script
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University
I tried to save the data with discord
I tried to correct the keystone of the image
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to notify the update of "Hamelin" using "Beautiful Soup" and "IFTTT"
I tried to automate internal operations with Docker, Python and Twitter API + bonus
I want to make a music player and file music at the same time
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
Make sure to align the pre-processing at the time of forecast model creation and forecast
The front engineer tried to automatically start go's API server with systemd quickly
[Introduction to AWS] I tried porting the conversation app and playing with text2speech @ AWS ♪
The story of making soracom_exporter (I tried to monitor SORACOM Air with Prometheus)
I tried to make a simple image recognition API with Fast API and Tensorflow
I tried to create a model with the sample of Amazon SageMaker Autopilot
I tried to compare the accuracy of Japanese BERT and Japanese Distil BERT sentence classification with PyTorch & Introduction of BERT accuracy improvement technique
I tried to learn the sin function with chainer