A lightweight GitHub webhook listener used internally by our team. It listens for push events on specific branches and triggers server restarts via the Pterodactyl API.
git clone https://github.com/AvionBlock/github-webhook.git
cd github-webhook
yarn installCopy the example file and fill in your values:
cp .env.example .envSee .env.example for descriptions of all required variables.
- Payload URL:
https://example.com/webhook - Content type:
application/json - Secret: Same as
GITHUB_SECRETin.env - Events: Only enable
push
yarn startFor development with watch mode:
yarn devBranch handlers are defined in branchConfig.ts like so:
export const branchHandlers = {
main: async () => {
return restartServer(process.env.PROD_SERVER_ID);
},
dev: async () => {
return restartServer(process.env.DEV_SERVER_ID);
},
};You can customize this file to trigger different actions per branch.
- Signature verification is enforced using
x-hub-signature-256 - The webhook should be served over HTTPS in production