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 install
Copy the example file and fill in your values:
cp .env.example .env
See .env.example
for descriptions of all required variables.
- Payload URL:
https://example.com/webhook
- Content type:
application/json
- Secret: Same as
GITHUB_SECRET
in.env
- Events: Only enable
push
yarn start
For development with watch mode:
yarn dev
Branch 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