Ever wanted to run an arbitrary script from anywhere with flexible authentication? Let me introduce ! Webhook I’ll show you how I set up to automatically render and deploy every time I push to on a instance. my blog master Gitea Install Install on the machine on which you want an automated action to occur. Webhook Go download the binary, or build it yourself. Webhook $ go get github.com/adnanh/webhook Configuration Create and a folder to contain everything. hooks.json $ mkdir webhook && cd webhook $ touch hooks.json Inside , copy this template, and update the location of the script you wish to execute. hooks.json [ { "id": "redeploy-blog", "execute-command": "/home/arran/hugo_websites/redeploy.sh", "command-working-directory": "/home/arran/", } ] For the curious, here’s what is inside my . redeploy.sh #!/bin/env bash REPO="${HOME}/hugo_websites/by.arran.nz/" git -C ${REPO} fetch && git -C ${REPO} rebase git -C ${REPO} submodule update --remote --rebase HUGO_CACHEDIR=${HOME}/tmp hugo --cleanDestinationDir --destination /var/www/virtual/${USER}/html --source ${REPO} Running I’m hosting on , and uses to manage services. my blog Uberspace Uberspace Supervisor If you’re not using Uberspace, run Webhook in any way you can on your machine. webhook -hooks hooks.json -logfile out.log -hotreload Supervisor To create a new service, make a file located at . ~/etc/services.d/webook.ini [program:webhook] directory=%(ENV_HOME)s/webhook autostart=true autorestart=true startretries=3 command=/home/arran/go/bin/webhook -hooks hooks.json -logfile out.log -hotreload After creating the configuration, tell supervisord to refresh its configuration and start the service: $ superviserctl reread $ superviserctl update $ supervisorctl status webhook RUNNING pid 13102, uptime 0:35:37 Check out the for further details. Uberspace supervisord manual Backend Uberspace If you’re using , configure the backend to point port to running under port - This is the default. Uberspace Uberspace 80 Webhook 9000 $ uberspace web backend set arran.uber.space --http --port 9000 Set backend for arran.uber.space/ to port 9000; please make sure something is listening! You can always check the status of your backend using "uberspace web backend list". For more information, check out the Uberspace Manual Sanity Check Now that a service is running and is exposed to the internet, test it. Considering the webhook is named , send a to: redeploy-blog POST $ curl -X POST https://arran.uber.space/hooks/redeploy-blog Confirm the webhook was successful by checking the logs located at as defined in . ~/webhook/out.log webhook.ini $ cat out.log ... [webhook] 2020/11/17 13:24:05 [7f6850] redeploy-blog got matched [webhook] 2020/11/17 13:24:05 [7f6850] redeploy-blog hook triggered successfully ... Secure the Webhook 🔐 Note: Make sure to setup with before implementing this step - Don’t go sending your secrets over ! Webhook https http You may have noticed anyone can call this Webhook - Let’s fix that. ’s git repository is currently hosted at , which is a instance. Configure to read the from a instance. My blog Codeberg Gitea Webhook secret Gitea Add a to the we created earlier - Replace the secret with your own. trigger-rule hooks.json [ { "id": "redeploy-blog", "execute-command": "/home/arran/hugo_websites/redeploy.sh", "command-working-directory": "/home/arran/", "trigger-rule": { "and": [ { "match": { "type": "value", "value": "____GITEA_SECRET____", "parameter": { "source": "payload", "name": "secret" } } }, { "match": { "type": "value", "value": "refs/heads/master", "parameter": { "source": "payload", "name": "ref" } } } ] } } ] Now will only allow execution when the request matches the . Webhook trigger-rule For further examples, reference the . Hook Examples Setting up Gitea Head on over to your Gitea instance’s repo , punch in the URL and secret, and you’re good to go! Repo > Settings > Webhooks Relax Now, every time you push to on a Gitea repository, the will be called - One more thing automated. master Webhook I hope you can generalize this information and add to your toolbox when you need to automate something simple in the future. Webhook No affiliation with or - But I can recommend them! Uberspace Codeberg