Compare commits

..

2 Commits

Author SHA1 Message Date
ktyl ed8eaa0ae8 Merge pull request 'add drone ci' (#1) from drone into main
continuous-integration/drone/push Build is passing Details
Reviewed-on: https://git.pizzawednesday.club/ktyl/ktyl.dev/pulls/1
2022-09-28 02:19:49 +02:00
ktyl d90ed17e6b add drone ci
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details
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
2022-09-28 01:16:23 +01:00
7 changed files with 117 additions and 16 deletions

71
.drone.yml Normal file
View File

@ -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

2
.gitmodules vendored
View File

@ -3,4 +3,4 @@
url = https://github.com/ktyldev/ppp url = https://github.com/ktyldev/ppp
[submodule "blog"] [submodule "blog"]
path = blog path = blog
url = https://github.com/ktyldev/blog.git url = https://git.pizzawednesday.club/ktyl/blog.git

12
Pipfile Normal file
View File

@ -0,0 +1,12 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
markdown = "*"
[dev-packages]
[requires]
python_version = "3.10"

29
Pipfile.lock generated Normal file
View File

@ -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": {}
}

View File

@ -32,6 +32,7 @@ HTML_TARGETS = $(PAGES:$(ROOT_DIR)/%.html=$(OUT_DIR)/%.html)
CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css) CSS_TARGETS = $(STYLES:$(ROOT_DIR)/%.css=$(OUT_DIR)/%.css)
PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png PNG_TARGETS = $(IMG_DIR)/%.png=$(OUT_DIR)/%.png
all: $(HTML_TARGETS) $(CSS_TARGETS) blog | $(OUT_DIR) all: $(HTML_TARGETS) $(CSS_TARGETS) blog | $(OUT_DIR)
cp $(IMG_DIR)/*.png $(OUT_DIR)/ cp $(IMG_DIR)/*.png $(OUT_DIR)/
cp $(IMG_DIR)/*.jpg $(OUT_DIR)/ cp $(IMG_DIR)/*.jpg $(OUT_DIR)/
@ -54,10 +55,10 @@ $(OUT_DIR):
blog: $(BLOG_TARGETS) $(BLOG_RSS) | $(BLOG_TMP_DIR) blog: $(BLOG_TARGETS) $(BLOG_RSS) | $(BLOG_TMP_DIR)
$(BLOG_RSS): $(BLOG_PAGES) $(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) $(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) $(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGETS)
python ppp/ppp.py $< $(HTML_INCLUDES) > $@ python ppp/ppp.py $< $(HTML_INCLUDES) > $@
@ -65,7 +66,7 @@ $(BLOG_OUT_DIR)/%.html: $(BLOG_OUT_DIR)/%.html.tmp $(HTML_INCLUDES) $(CSS_TARGET
rm $< rm $<
$(BLOG_OUT_DIR)/%.html.tmp: $(BLOG_SRC_DIR)/%.md | $(BLOG_TMP_DIR) $(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) $(BLOG_OUT_DIR): | $(OUT_DIR)
mkdir -p $@ mkdir -p $@

View File

@ -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

View File

@ -16,8 +16,6 @@
#include socials.html #include socials.html
</p> </p>
</div> </div>
#include planets.html #include planets.html