From b6e0ef44f4b33baa187fee1e5757c44bd121dac7 Mon Sep 17 00:00:00 2001 From: lubiana Date: Sun, 23 Jun 2024 11:58:18 +0200 Subject: [PATCH 1/2] write release workflow file --- .forgejo/workflows/release.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index a1c6c78..72b4710 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -18,6 +18,27 @@ jobs: git checkout ${{ github.head_ref }} - name: prepare deploy run: sh ./deploy/prepare-deploy.sh + - name: deploy + env: + HOST: 'web.server.c3h' + USERNAME: 'c3h-futtern' + TARGETDIR: '/home/c3h-futtern/futtern' + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + run: | + mkdir -p ~/.ssh/ + # Print the SSH key, replacing newline characters with actual new lines + echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa + # Set appropriate permissions for the SSH key + chmod 600 ~/.ssh/id_rsa + # Add the remote host's key to the known_hosts file to avoid authenticity confirmation + ssh-keyscan -H $HOST >> ~/.ssh/known_hosts + # stop services + ssh ${USERNAME}@${HOST} systemctl --user stop pod-futtern + # SCP files to the remote host + rsync -avz --delete deploy/ ${USERNAME}@${HOST}:${TARGETDIR} --exclude=var + # run update script + ssh ${USERNAME}@${HOST} /home/c3h-futtern/futtern/update.sh + - + -- 2.39.5 From 57b4e330281db40bc9d76f7e8221a77937b1c225 Mon Sep 17 00:00:00 2001 From: lubiana Date: Mon, 24 Jun 2024 21:19:11 +0200 Subject: [PATCH 2/2] fix paths in prepare deploy and add local deploy script --- deploy/local-deploy.sh | 6 ++++++ deploy/prepare-deploy.sh | 3 ++- deploy/update.sh | 0 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 deploy/local-deploy.sh mode change 100644 => 100755 deploy/update.sh diff --git a/deploy/local-deploy.sh b/deploy/local-deploy.sh new file mode 100755 index 0000000..77189ad --- /dev/null +++ b/deploy/local-deploy.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +. ./deploy/prepare-deploy.sh +ssh leitstelle-futtern 'systemctl --user stop pod-futtern' +rsync -avz --delete deploy/ leitstelle-futtern:futtern --exclude=var +ssh leitstelle-futtern '/home/c3h-futtern/futtern/update.sh' diff --git a/deploy/prepare-deploy.sh b/deploy/prepare-deploy.sh index 5bb412a..6a80baa 100755 --- a/deploy/prepare-deploy.sh +++ b/deploy/prepare-deploy.sh @@ -17,6 +17,7 @@ done rm ./bin/phpunit APP_ENV=prod composer install --no-dev -a +rm -rf ./var/cache - +cd - diff --git a/deploy/update.sh b/deploy/update.sh old mode 100644 new mode 100755 -- 2.39.5