From e703c27d4bac9eb59d1648a9d2706963d77109f5 Mon Sep 17 00:00:00 2001 From: maren Date: Mon, 8 Jan 2024 09:27:22 -0500 Subject: [PATCH] do ci better hopefully --- .woodpecker.yml | 35 ----------------------------------- .woodpecker/.woodpecker.yml | 29 +++++++++++++++++++++++++++++ .woodpecker/deploy.sh | 22 ++++++++++++++++++++++ 3 files changed, 51 insertions(+), 35 deletions(-) delete mode 100644 .woodpecker.yml create mode 100644 .woodpecker/.woodpecker.yml create mode 100755 .woodpecker/deploy.sh diff --git a/.woodpecker.yml b/.woodpecker.yml deleted file mode 100644 index 7c2df29..0000000 --- a/.woodpecker.yml +++ /dev/null @@ -1,35 +0,0 @@ -when: - branch: - include: [ main ] - -steps: - - build: - image: debian:bookworm-slim - commands: - - apt update - # - rm -rf data/ - # - rm -rf in-progress - - apt -yq install racket ca-certificates - - yes Y | raco pkg install --no-docs csv-reading - - raco exe sorrel.dev.rkt - - raco distribute dist sorrel.dev - - deploy: - image: alpine:latest - secrets: [ deploy_ssh_key ] - commands: - - apk add openssh - - mkdir ~/.ssh - - printf '%s\n' "$${DEPLOY_SSH_KEY}" > ~/.ssh/deploy_ssh_key - - printf "Host turtle.hup.is\n\tIdentityFile ~/.ssh/deploy_ssh_key\n\tUserKnownHostsFile=/dev/null\n\tStrictHostKeyChecking=no\n" > ~/.ssh/config - - chmod -R u=rwX,go= ~/.ssh - - mkdir oxaliq - - mv dist oxaliq/. - - mv source oxaliq/. - - mv static oxaliq/. - - scp -r oxaliq deploy@turtle.hup.is:~/ - - ssh deploy@turtle.hup.is 'sudo rm -rf /srv/oxaliq || true && sudo mv oxaliq /srv/. && sudo systemctl restart sorreldotdev.service' - when: - # Only try to deploy if previous step is successful - status: success diff --git a/.woodpecker/.woodpecker.yml b/.woodpecker/.woodpecker.yml new file mode 100644 index 0000000..6204084 --- /dev/null +++ b/.woodpecker/.woodpecker.yml @@ -0,0 +1,29 @@ +when: + branch: + exclude: [ main ] + +steps: + + build: + image: debian:bookworm-slim + commands: + - apt update + - apt -yq install racket ca-certificates + - yes Y | raco pkg install --no-docs csv-reading + - raco exe sorrel.dev.rkt + - raco distribute dist sorrel.dev + + deploy: + image: alpine:latest + secrets: + - deploy_ssh_key + commands: + - apk add openssh-client + - mkdir -p $HOME/.ssh + - ssh-keyscan -t ed25519 turtle.hup.is >> $HOME/.ssh/known_hosts + - echo "$DEPLOY_SSH_KEY" > $HOME/.ssh/id_ed25519 + - chmod 0600 $HOME/.ssh/id_ed25519 + - ./.woodpecker/deploy.sh + when: + # Only try to deploy if previous step is successful + status: success diff --git a/.woodpecker/deploy.sh b/.woodpecker/deploy.sh new file mode 100755 index 0000000..33220f5 --- /dev/null +++ b/.woodpecker/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/sh -e + +# hello variables +host=deploy@turtle.hup.is + +# organize the files +mkdir oxaliq +mv dist oxaliq/. +mv source oxaliq/. +mv static oxaliq/. + +# put them on the deployment target +scp -r oxaliq $host + +# do everything on the server that's necessary to run the new thing +# TODO make this not remove the old-working version until +# the new version is confirmed working +ssh $host 'sudo chown -R sorreldotdev:sorreldotdev oxaliq/' +ssh $host 'sudo chmod -R 755 oxaliq/' +ssh $host 'sudo rm -rf /srv/oxaliq || true' +ssh $host 'sudo mv oxaliq /srv/.' +ssh $host 'sudo systemctl restart sorreldotdev.service'