Code Monkey home page Code Monkey logo

git_hook_and_line_notify's Introduction

當專案沒有放在任何的lab上(gitlab github ...etc),只有使用檔案更新,可以利用git hook 來發送 commit 通知。

使用 git hook 執行 python 並發送 Line 群組通知

git hook 是 Git 提供的事件觸發 script 腳本,sample 檔都會放在 Repository .git/hooks 內,此專案選用 Server-side hooks 的 post-receive (在整個過程執行完後執行,可以用來更新其他系統或通知)

直接把三個檔案複製到.git/hooks內 (注意! hooks 必須是放在 server 內的 git repository)

cp -r post-receive repository_name/.git/hooks cp -r post-receive.py repository_name/.git/hooks cp -r config.ini repository_name/.git/hooks

config.ini 內加入line notify 申請對應的聊天室權杖

channel_access_token = "token"

project name 是自定義的(更新專案使用的名稱)

project_name = "專案名稱"

post-receive.py 是通知 line notify 的執行檔案 config.ini 要和此檔放在同一層,如果要直接執行發送,也可執行以下指令

python3 post-receive.py

參考資料

Windows 環境下為 Git Repository 加上 Git Hook

提升程式碼品質:使用 Pre-Commit (Git Hooks)

Git hook 快速指南

python 實作發送line notify 訊息

git_hook_and_line_notify's People

Contributors

carriechia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.