github webhook printing
1.0.0
Print (certain) GitHub webhook events with a thermal printer.
mkdir -p /var/www/cgi/
git clone [email protected]:alifeee/github-webhook-printing.git
mv github-webhook-printing githubwebhooks
cd githubwebhooks
chown -R alifeee:www-data .apt install nginx fcgiwrap
service nginx start
echo 'server {
listen 80;
listen [::]:80;
server_name <server-address>;
location /githubwebhooks {
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/cgi/$fastcgi_script_name;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}' > /etc/nginx/sites-available/githubwebhook
ln -s /etc/nginx/sites-available/githubwebhook /etc/nginx/sites-enabled/githubwebhook
nginx -t
ufw allow 80
service nginx restartcurl "http://<server-address>/githubwebhooks/ping.cgi"Go to a GitHub user, repository, or organisation settings page > webhooks. Add a webhook that points to http://<server-address>/githubwebhooks/hook.cgi.
Send some webhook requests (by activating GitHub events).
Copy and paste the env output and data from the log file to files like webhook-examples/push.env and webhook-examples/push.json.
Set the webhook to point to http://<server-address>/githubwebhooks/hook.cgi
# push
curl -s --request POST -i -H "X-GITHUB-EVENT: push" "http://<server-address>/githubwebhooks/hook.cgi" -d "@webhook-examples/push.json"
# issue_comment
curl -s --request POST -i -H "X-GITHUB-EVENT: issue_comment" "http://<server-address>/githubwebhooks/hook.cgi" -d "@webhook-examples/issue_comment.json"
# create
curl -s --request POST -i -H "X-GITHUB-EVENT: create" "http://<server-address>/githubwebhooks/hook.cgi" -d "@webhook-examples/create.json"
# pull_request
curl -s --request POST -i -H "X-GITHUB-EVENT: pull_request" "http://<server-address>/githubwebhooks/hook.cgi" -d "@webhook-examples/pull_request.json"