Skip to content

Automatic Wildcard Cert #10

Automatic Wildcard Cert

Automatic Wildcard Cert #10

name: "Automatic Wildcard Cert"
on:
schedule:
- cron: '0 0 1 */2 *' # At 00:00, on day 1 of the month, every 2 months
jobs:
Update-Wildcard-Cert:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
- name: "Create Cloudflare key file"
shell: "bash"
env:
CLOUDFLARE_DNS_API_TOKEN: "${{ secrets.DNS_CLOUDFLARE_API_TOKEN }}"
run: |
sudo mkdir /root/.secrets
sudo touch /root/.secrets/cloudflare
sudo chmod 600 /root/.secrets/cloudflare
printf 'dns_cloudflare_api_token = "%s"' "$CLOUDFLARE_DNS_API_TOKEN" | sudo tee /root/.secrets/cloudflare
- name: "certbot a new cert"
shell: "bash"
run: |
sudo apt update && sudo apt install python3-certbot certbot python3-certbot-nginx python3-certbot-dns-cloudflare python3-cloudflare -y
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/cloudflare -d "*.logfather.org" --preferred-challenges dns-01 --register-unsafely-without-email --agree-tos --dns-cloudflare-propagation-seconds 300
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials /root/.secrets/cloudflare -d "osadmin.logfather.org" --preferred-challenges dns-01 --register-unsafely-without-email --agree-tos --dns-cloudflare-propagation-seconds 300
echo "${{ secrets.CERT_ENC_PWD }}" > .pwd
privkey=$(sudo readlink -f /etc/letsencrypt/live/logfather.org/privkey.pem) && sudo openssl enc -in $privkey -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/privkey.pem.enc
cert=$(sudo readlink -f /etc/letsencrypt/live/logfather.org/cert.pem) && sudo openssl enc -in $cert -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/cert.pem.enc
cachain=$(sudo readlink -f /etc/letsencrypt/live/logfather.org/fullchain.pem) && sudo openssl enc -in $cachain -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/fullchain.pem.enc
osadmin_privkey=$(sudo readlink -f /etc/letsencrypt/live/osadmin.logfather.org/privkey.pem) && sudo openssl enc -in $osadmin_privkey -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/osadmin_privkey.pem.enc
osadmin_cert=$(sudo readlink -f /etc/letsencrypt/live/osadmin.logfather.org/cert.pem) && sudo openssl enc -in $osadmin_cert -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/osadmin_cert.pem.enc
osadmin_cachain=$(sudo readlink -f /etc/letsencrypt/live/osadmin.logfather.org/fullchain.pem) && sudo openssl enc -in $osadmin_cachain -aes-256-cbc -pbkdf2 -pass file:.pwd > certs/osadmin_fullchain.pem.enc
sudo rm .pwd
git config user.name github-actions
git config user.email [email protected]
git add .
git commit -m "Git Actions Updated Wildcard Certificate"
git push