From b6e0ef44f4b33baa187fee1e5757c44bd121dac7 Mon Sep 17 00:00:00 2001 From: lubiana Date: Sun, 23 Jun 2024 11:58:18 +0200 Subject: [PATCH] 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 + - +