Note
A minimal Flask application to handle github webhook.
Run git pull
automanticly.
Steps: add repoName&repoPath to config.toml, then run daemon only.
Note
一个用于处理 github webhook 的极简 Flask 应用程序。
自动运行 git pull
。
步骤:将 repoName&repoPath 添加到 config.toml,然后仅运行守护进程。
- Set up github webhook (Payload URL and SECRET)
- Set up a server to handle webhook requests (HTTP POST)
- Python environment
- PM2 (Node.js process manager) to run and monitor the Python script
set webhook Payload URL, ex. https://webhook.jokerpy.top/pool
Note: Use pool
as the repo alias to run the local path (match step 3 repoName)
set Content type application/json
(current only json is tested & supported)
make sure https://webhook.jokerpy.top/pool
can be finded by flask
copy config.toml.example to config.toml.
-
[repo.repoName]
repoName represents the repo alias set in step 1 -
path
specifies the local path on the server corresponding to the GitHub repository (e.g., the directory where you want to execute commands) (cd path) -
secret
is the github webhook SECRET (step 1) -
command
is the command aftercd path &&
, for examplegit fetch && git rebase
poetry run python init.py
poetry run python main.py
Configure PM2 to monitor and run the Python script as a daemon. You can use a Makefile or shell script to trigger PM2.
Example command:
pm2 start ./run.sh --name HookScript --silent --log
This command starts a new PM2 process named HookScript, runs silently, and logs the output
Tip
restart project itself, add these to config.toml as command command = "git pull && (sleep 10; make reload) &"
By following these steps, you can successfully set up a server to handle GitHub webhook requests, process the payloads, and execute actions based on the received data.