diff --git a/.woodpecker/build-and-deploy.yml b/.woodpecker/build-and-deploy.yml index 015e94a..07e8888 100644 --- a/.woodpecker/build-and-deploy.yml +++ b/.woodpecker/build-and-deploy.yml @@ -18,7 +18,14 @@ steps: secrets: - deploy_ssh_key commands: - - ./.woodpecker/ssh.sh + - echo "SETTING UP SSH" + - 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 + - echo "SSH SETUP DONE" + - echo "RUNNING DEPLOY SCRIPT" - ./.woodpecker/deploy.sh when: # Only try to deploy if previous step is successful diff --git a/.woodpecker/deploy.sh b/.woodpecker/deploy.sh index 3a4d7ca..89bd312 100755 --- a/.woodpecker/deploy.sh +++ b/.woodpecker/deploy.sh @@ -4,20 +4,29 @@ host=deploy@turtle.hup.is # organize the files +echo "ORGANIZING THE FILES NICELY" mkdir oxaliq mv dist oxaliq/. mv source oxaliq/. mv static oxaliq/. # put them on the deployment target +echo "COPYING FILES TO 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 'echo "does this ls show up in UI?" && ls -la' +echo "SETTING OWNERSHIP AND PERMISSIONS" ssh $host 'sudo chown -R sorreldotdev:sorreldotdev oxaliq/' ssh $host 'sudo chmod -R 755 oxaliq/' + +echo "REPLACING PREVIOUS DEPLOYMENT" ssh $host 'sudo rm -rf /srv/oxaliq || true' ssh $host 'sudo mv oxaliq /srv/.' + +echo "RESTARTING SERVICE" ssh $host 'sudo systemctl restart sorreldotdev.service' + +echo "SUCCESS!" +exit 0 diff --git a/.woodpecker/ssh.sh b/.woodpecker/ssh.sh deleted file mode 100755 index 64eb97c..0000000 --- a/.woodpecker/ssh.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -e - -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