Deploy GitHub repos to a VPS on push via webhooks
npm install petadepDeploy GitHub repos to a VPS on push via GitHub webhooks or a GitHub App.
``bash`
npm install
Make the CLI executable:
`bash`
chmod +x bin/petadep.js
`bash`
petadep
Interactive setup will ask for port, webhook path, secret, deployment info, and where to save the config.
If you prefer the non-interactive command:
`bash`
petadep init --config ./data/config.json
This creates ./data/config.json, ./data/, and ./logs/, prints the webhook secret, and shows the next step.
`bash`
petadep add --config ./data/config.json \
--repo owner/repo \
--branch staging \
--env staging \
--workdir /var/www/repo-staging \
--script ./deploy/staging.sh
`bash`
petadep agent --config ./data/config.json
To install/use PM2 and run the agent under it:
`bash`
petadep agent --config ./data/config.json --pm2
The server exposes:
- POST /webhook (or config.path)GET /health
-
- Webhook URL: http://YOUR_VPS_IP:8787/webhook (match config.path)init
- Secret: the value printed by (also stored in the config)push
- Events: (or update security.allowedEvents)
If using a GitHub App, set the same URL/secret in the App's webhook settings.
The agent clones via SSH using git@github.com:owner/repo.git. Your VPS must have a deploy key or SSH key with access to the repo. Add the VPS public key as a Deploy key in GitHub (read-only is fine).
`json`
{
"port": 8787,
"path": "/webhook",
"secret": "
"sshKeyPath": "/root/.ssh/petadep_ed25519",
"deployments": [
{
"repo": "owner/repo",
"branch": "staging",
"env": "staging",
"workdir": "/var/www/repo-staging",
"script": "./deploy/staging.sh"
}
],
"security": { "allowedEvents": ["push"], "lockPerTarget": true, "timeoutSeconds": 900 },
"logsDir": "./logs"
}
sshKeyPath` is optional and forces git to use that SSH key for clone/fetch.