Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alifeee/github-webhook-printing
Printing GitHub webhook events with a ZJ-58 receipt printer
https://github.com/alifeee/github-webhook-printing
cgi escpos thermal-printer webhooks zj-58
Last synced: 23 days ago
JSON representation
Printing GitHub webhook events with a ZJ-58 receipt printer
- Host: GitHub
- URL: https://github.com/alifeee/github-webhook-printing
- Owner: alifeee
- Created: 2024-07-11T17:47:54.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-23T13:30:14.000Z (4 months ago)
- Last Synced: 2024-07-24T14:55:40.795Z (4 months ago)
- Topics: cgi, escpos, thermal-printer, webhooks, zj-58
- Language: Shell
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GitHub webhook printing
Print (certain) GitHub webhook events with a thermal printer.
## Install
```bash
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 .
```## Use Nginx to turn on CGI scripts
```bash
apt install nginx fcgiwrap
service nginx start
echo 'server {
listen 80;
listen [::]:80;server_name ;
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 restart
```## Test ping CGI script
```bash
curl "http:///githubwebhooks/ping.cgi"
```## Collect example webhook payloads
Go to a GitHub user, repository, or organisation settings page > webhooks. Add a webhook that points to `http:///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`.
## Test webhook
Set the webhook to point to `http:///githubwebhooks/hook.cgi`
```bash
# push
curl -s --request POST -i -H "X-GITHUB-EVENT: push" "http:///githubwebhooks/hook.cgi" -d "@webhook-examples/push.json"
# issue_comment
curl -s --request POST -i -H "X-GITHUB-EVENT: issue_comment" "http:///githubwebhooks/hook.cgi" -d "@webhook-examples/issue_comment.json"
# create
curl -s --request POST -i -H "X-GITHUB-EVENT: create" "http:///githubwebhooks/hook.cgi" -d "@webhook-examples/create.json"
# pull_request
curl -s --request POST -i -H "X-GITHUB-EVENT: pull_request" "http:///githubwebhooks/hook.cgi" -d "@webhook-examples/pull_request.json"
```## To-do
- print a QR code that links to the event (QR code printing with ESCPOS *without* using a library like [python-escpos] or [node-escpos] is difficult)
- add more events![python-escpos]: https://github.com/python-escpos/python-escpos/
[node-escpos]: https://github.com/node-escpos/driver