From 838db59663fc0771ff64eba4ec4661469f413691 Mon Sep 17 00:00:00 2001 From: ktyl Date: Mon, 26 Sep 2022 19:27:41 +0100 Subject: [PATCH] add drone ci config --- .drone.yml | 38 ++++++++++++++++++++++++++++++++++++++ deploy.sh | 20 -------------------- makefile | 21 --------------------- 3 files changed, 38 insertions(+), 41 deletions(-) create mode 100644 .drone.yml delete mode 100644 deploy.sh delete mode 100644 makefile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..6bfdc57 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,38 @@ +kind: pipeline +type: docker +name: deploy + +steps: +- name: deploy + image: ubuntu + environment: + HOST: + from_secret: host + USER: + from_secret: user + SSH_KEY: + from_secret: ssh_key + SRC: content + when: + branch: + - main + + commands: + # install stuff + - apt-get update -qq > /dev/null + - apt-get install ssh rsync -qq > /dev/null + + # configure ssh identity by importing ssh key from secrets and adding it to + # ssh-agent. also disable strict host key checking as this is the first time + # the ephemeral runner is connecting to the remote host + - which ssh-agent + - 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 + + # run operations on the remote host + - ssh "$${USER}@$${HOST}" "[[ ! -d ~/gemini/content ]] || rm -r ~/gemini/content" + - rsync -rP content "$${USER}@$${HOST}:gemini" diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index cfa980b..0000000 --- a/deploy.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -site=period3.xyz -gemini=/home/gemini/gemini -dest="$gemini/content" - -# remove existing files -sudo rm -rv $dest - -# copy received files to hosting location -sudo mv $site $dest -sudo chown -R gemini:gemini $dest - -# delete self -rm -v deploy.sh - -printf "\ndone!\n" - - - diff --git a/makefile b/makefile deleted file mode 100644 index 150988f..0000000 --- a/makefile +++ /dev/null @@ -1,21 +0,0 @@ -.DEFAULT_GOAL := $(SITE) - -SITE = period3.xyz - -HOST = pluto -HOST_DIR = $(HOST):~ - -CONTENT = content/ -DEPLOY = deploy.sh - -# to deploy the site we copy a deploy script and the site -# contents over to the remote host, then run the deploy script -# which is used to place the site files in the hosted root folder -# we then delete the built site directory locally to avoid accidentally -# caching stuff for future deploys -deploy: $(CONTENT) - rsync -rP $(CONTENT) $(SITE) - rsync -P $(DEPLOY) $(HOST_DIR) - rsync -rP $(SITE) $(HOST_DIR) - ssh $(HOST) "bash -s" < $(DEPLOY) - rm -r $(SITE)