From b16e91d1995146ad1308f68cd6057c538cbca994 Mon Sep 17 00:00:00 2001 From: ktyl Date: Tue, 27 Sep 2022 08:32:11 +0100 Subject: [PATCH] add drone ci update submodule url use arch image remove defunct deploy script use pipenv extract build stage connect to remote server deploy with ubuntu copy old site copy new site to host deploy new site only deploy on main --- .drone.yml | 71 +++++++++++++++++++++++++++++++++++++++++ .gitmodules | 2 +- Pipfile | 12 +++++++ Pipfile.lock | 29 +++++++++++++++++ makefile | 8 ++--- scripts/deploy-ktyl.dev | 10 ------ src/root/index.html | 2 -- 7 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 .drone.yml create mode 100644 Pipfile create mode 100644 Pipfile.lock delete mode 100755 scripts/deploy-ktyl.dev diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..301ae35 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,71 @@ +kind: pipeline +type: docker +name: deploy + +steps: +- name: submodules + image: archlinux + commands: + - pacman -Sy --noconfirm git >/dev/null + - git submodule update --init --recursive + +- name: build + image: archlinux + environment: + PYTHON_ENV: python python-pipenv python-setuptools + + commands: + # set up python + - pacman -Sy --noconfirm make $PYTHON_ENV > /dev/null + - pipenv install + + # build site + - make all + +- name: deploy + image: ubuntu + environment: + HOST: + from_secret: host + USER: + from_secret: user + SSH_KEY: + from_secret: ssh_key + + when: + branch: + - main + + commands: + # install deps + - apt-get update -qq > /dev/null + - apt-get install ssh rsync -qq > /dev/null + + # configure ssh + - eval $(ssh-agent -s) + - mkdir -p ~/.ssh + - echo "$SSH_KEY" > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - ssh-add + - echo "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config + + # prepare vars for host operations + - host_dir="/var/www/$${HOST}" + - backup_dir="~/backups/$${HOST}/$${HOST}-$${DRONE_STAGE_STARTED}" + - host="$${USER}@$${HOST}" + + # tasks + - make_backup_dir="mkdir -p $backup_dir" + - copy_backup_files="rsync -rP $host_dir $backup_dir" + - delete_current_files="sudo -n rm -r $host_dir" + - deploy_new_files="sudo -n mv $${HOST} $host_dir" + + # archive old site + - ssh $host $make_backup_dir + - ssh $host $copy_backup_files + + # deploy new site + - rsync -rP site/* "$host:$${HOST}" + - ssh $host $delete_current_files + - ssh $host $deploy_new_files + diff --git a/.gitmodules b/.gitmodules index c96c38c..11fb95f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/ktyldev/ppp [submodule "blog"] path = blog - url = https://github.com/ktyldev/blog.git + url = https://git.pizzawednesday.club/ktyl/blog.git diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..950de58 --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +markdown = "*" + +[dev-packages] + +[requires] +python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..868cdbc --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,29 @@ +{ + "_meta": { + "hash": { + "sha256": "4f4f4fc0dc77addc9a4bf6c737f31df9507ee22a83548fcff1891a4e7bc27bed" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.10" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "markdown": { + "hashes": [ + "sha256:08fb8465cffd03d10b9dd34a5c3fea908e20391a2a90b88d66362cb05beed186", + "sha256:3b809086bb6efad416156e00a0da66fe47618a5d6918dd688f53f40c8e4cfeff" + ], + "index": "pypi", + "version": "==3.4.1" + } + }, + "develop": {} +} diff --git a/makefile b/makefile index 3102f9d..b043da7 100644 --- a/makefile +++ b/makefile @@ -32,7 +32,7 @@ HTML_TARGETS = $(PAGES:$(ROOT_DIR)/%.html=$(OUT_DIR)/%.html) CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css) PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png -site: $(HTML_TARGETS) $(CSS_TARGETS) +all: $(HTML_TARGETS) $(CSS_TARGETS) blog | $(OUT_DIR) cp $(IMG_DIR)/*.png $(OUT_DIR)/ cp $(IMG_DIR)/*.jpg $(OUT_DIR)/ @@ -56,10 +56,10 @@ $(OUT_DIR): blog: $(BLOG_TARGETS) $(BLOG_RSS) | $(BLOG_TMP_DIR) $(BLOG_RSS): $(BLOG_PAGES) - python scripts/mkblogrss.py $(BLOG_PAGES) > $@ + pipenv run python scripts/mkblogrss.py $(BLOG_PAGES) > $@ $(BLOG_INDEX_LINKS): $(BLOG_TARGETS) | $(BLOG_TMP_DIR) - python scripts/mkblogindex.py $(BLOG_TARGETS) > $@ + pipenv run python scripts/mkblogindex.py $(BLOG_TARGETS) > $@ $(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGETS) python ppp/ppp.py $< $(HTML_INCLUDES) > $@ @@ -67,7 +67,7 @@ $(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGET rm $< $(BLOG_OUT_DIR)/%.html.tmp: $(BLOG_SRC_DIR)/%.md | $(BLOG_TMP_DIR) - python scripts/mkblog.py $< $@ + pipenv run python scripts/mkblog.py $< $@ $(BLOG_OUT_DIR): | $(OUT_DIR) mkdir -p $@ diff --git a/scripts/deploy-ktyl.dev b/scripts/deploy-ktyl.dev deleted file mode 100755 index 5ccd339..0000000 --- a/scripts/deploy-ktyl.dev +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -site="ktyl.dev" -srcdir="./$site" -webroot="/var/www" -sitedir="$webroot/$site" - - -[ -d $sitedir ] && rm -r $sitedir -sudo -n mv $srcdir $webroot diff --git a/src/root/index.html b/src/root/index.html index d708f0a..073e6b5 100644 --- a/src/root/index.html +++ b/src/root/index.html @@ -16,8 +16,6 @@ #include socials.html

- - #include planets.html