These are my scripts to automatically renew my certificates using letsencrypts and the hetzner API.
The TXT records through the hetzner API are needed in order to obtain wildcard certificates.
Just install these file (renew-certificate can be located anywhere, just adjust it's path in the file itself.)
Make sure you have installed certbot and jq.
Then, obtain an API token from hetzner, fill in your API key and domains into renew-certificates and run the renew-certificates file.
This should obtain the certificates for the first time, verifying all your domains in the process.
Afterwards, you can just run certbot renew periodically (for example through a cronjob), which should renew your certificates automatically, if needed.
You will be able to find your certificates in /etc/letsencrypt/live/*. You could configure your web server to use the certs from that folder.
Don't forget to restart your web server upon certificate renewal through a hook, for example through /etc/letsencrypt/renewal-hooks/deploy/00-restart-webserver
Here is where the files belong:
renew-certificates: anywhere, should stay there and be executable
dns-clean: /etc/letsencrypt/renewal-hooks/pre/00-dns-clean
dns-clean: symlink to /etc/letsencrypt/renewal-hooks/post/00-dns-clean -> /etc/letsencrypt/renewal-hooks/pre/00-dns-clean
00-restart-webserver: /etc/letsencrypt/renewal-hooks/deploy/00-restart-webserver