From d2d55dcedb723a2afbf182092b2c2363a730c211 Mon Sep 17 00:00:00 2001 From: lostinlight Date: Wed, 19 Jan 2022 20:27:26 +0300 Subject: [PATCH] Remove files irrelevant for Codeberg pages --- .gitlab-ci.yml | 63 ------------------------------------ letsencrypt_authenticator.sh | 25 -------------- letsencrypt_cleanup.sh | 7 ---- letsencrypt_generate.sh | 19 ----------- 4 files changed, 114 deletions(-) delete mode 100644 .gitlab-ci.yml delete mode 100644 letsencrypt_authenticator.sh delete mode 100644 letsencrypt_cleanup.sh delete mode 100644 letsencrypt_generate.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index bdfb307..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,63 +0,0 @@ - -image: node:12.22.1 - -hexo: - stage: build - before_script: - - npm install gulp -g - - npm install hexo-cli -g - - npm install - script: - - gulp build --cwd ./themes/starter - - hexo generate - artifacts: - paths: - - public/ - cache: - paths: - - node_modules/ - key: project - only: - - main - -htmlproofer: - stage: test - image: olikami/htmlproofer:latest # fork of 18fgsa/html-proofer - only: - variables: - - $CI_COMMIT_MESSAGE =~ /htmlproofer/ - script: - - htmlproofer public/ --external-only --checks-to-ignore ScriptCheck,ImageCheck - dependencies: - - hexo - -pages: - stage: deploy - variables: - GIT_STRATEGY: none - artifacts: - paths: - - public/ - dependencies: - - hexo - script: - - echo 'Deploying...' - only: - - main - -cert-renewal: - only: - - schedules - variables: - CERTBOT_RENEWAL_GIT_TOKEN: $CERTBOT_RENEWAL_GIT_TOKEN - script: - - echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list - - apt-get update - - apt-get install certbot -t stretch-backports -y - - apt-get install git curl -y - - export PATH=$PATH:$CI_PROJECT_DIR - - git config --global user.name $GITLAB_USER_LOGIN - - git config --global user.email $GITLAB_USER_EMAIL - - chmod +x ./letsencrypt_generate.sh - - chmod +x ./letsencrypt_authenticator.sh - - ./letsencrypt_generate.sh diff --git a/letsencrypt_authenticator.sh b/letsencrypt_authenticator.sh deleted file mode 100644 index 3063563..0000000 --- a/letsencrypt_authenticator.sh +++ /dev/null @@ -1,25 +0,0 @@ - -#!/bin/bash -# source https://www.harenslak.nl/blog/https-letsencrypt-gitlab-hugo - -mkdir -p $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge -echo $CERTBOT_VALIDATION > $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge/$CERTBOT_TOKEN -git add $CI_PROJECT_DIR/source/_static/.well-known/acme-challenge/$CERTBOT_TOKEN -git commit -m "GitLab runner - Added certbot challenge file for certificate renewal" -git push https://$GITLAB_USER_LOGIN:$CERTBOT_RENEWAL_GIT_TOKEN@gitlab.com/fediverse/fediverse.gitlab.io.git HEAD:master - -interval_sec=15 -max_tries=80 # ~20 minutes -n_tries=0 -while [ $n_tries -le $max_tries ] -do - status_code=$(curl -L --write-out "%{http_code}\n" --silent --output /dev/null https://fediverse.party/.well-known/acme-challenge/$CERTBOT_TOKEN) - if [ $status_code -eq 200 ]; then - exit 0 - fi - - n_tries=$((n_tries+1)) - sleep $interval_sec -done - -exit 1 diff --git a/letsencrypt_cleanup.sh b/letsencrypt_cleanup.sh deleted file mode 100644 index 008943c..0000000 --- a/letsencrypt_cleanup.sh +++ /dev/null @@ -1,7 +0,0 @@ - -#!/bin/bash -# source https://www.harenslak.nl/blog/https-letsencrypt-gitlab-hugo - -git rm $CI_PROJECT_DIR/static/.well-known/acme-challenge/$CERTBOT_TOKEN -git commit -m "GitLab runner - Removed certbot challenge file" -git push https://$GITLAB_USER_LOGIN:$CERTBOT_RENEWAL_GIT_TOKEN@gitlab.com/fediverse/fediverse.gitlab.io.git HEAD:master diff --git a/letsencrypt_generate.sh b/letsencrypt_generate.sh deleted file mode 100644 index 28dee38..0000000 --- a/letsencrypt_generate.sh +++ /dev/null @@ -1,19 +0,0 @@ - -#!/bin/bash -# source https://www.harenslak.nl/blog/https-letsencrypt-gitlab-hugo - -end_epoch=$(date -d "$(echo | openssl s_client -connect fediverse.party:443 -servername fediverse.party 2>/dev/null | openssl x509 -enddate -noout | cut -d'=' -f2)" "+%s") -current_epoch=$(date "+%s") -renew_days_threshold=30 -days_diff=$((($end_epoch - $current_epoch) / 60 / 60 / 24)) - -if [ $days_diff -lt $renew_days_threshold ]; then - ls - echo "Certificate is $days_diff days old, renewing now." - certbot certonly --manual --debug --preferred-challenges=http -m $GITLAB_USER_EMAIL --agree-tos --manual-auth-hook letsencrypt_authenticator.sh --manual-public-ip-logging-ok -d fediverse.party -d www.fediverse.party - echo "Certbot finished. Updating GitLab Pages domains." - curl --request PUT --header "PRIVATE-TOKEN: $CERTBOT_RENEWAL_GIT_TOKEN" --form "certificate=@/etc/letsencrypt/live/fediverse.party/fullchain.pem" --form "key=@/etc/letsencrypt/live/fediverse.party/privkey.pem" https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pages/domains/fediverse.party - curl --request PUT --header "PRIVATE-TOKEN: $CERTBOT_RENEWAL_GIT_TOKEN" --form "certificate=@/etc/letsencrypt/live/fediverse.party/fullchain.pem" --form "key=@/etc/letsencrypt/live/fediverse.party/privkey.pem" https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pages/domains/www.fediverse.party -else - echo "Certificate still valid for $days_diff days, no renewal required." -fi