deployyyyy
All checks were successful
/ ls (pull_request) Successful in 1m35s

This commit is contained in:
lubiana 2025-06-15 01:41:25 +02:00
parent d468d5a6e3
commit d442b2e522
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
11 changed files with 318 additions and 0 deletions

View file

@ -0,0 +1,49 @@
on:
release
jobs:
ls:
runs-on: docker
container:
image: git.php.fail/lubiana/container/php:8.4.8-ci
steps:
- name: Manually checkout
env:
REPO: '${{ github.repository }}'
TOKEN: '${{ secrets.GITHUB_TOKEN }}'
BRANCH: '${{ env.GITHUB_REF_NAME }}'
GIT_SERVER: 'hannover.ccc.de/gitlab'
run: |
git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git .
git fetch
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/saufen'
HOMEDIR: '/home/c3h-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-saufen
# backup database
ssh ${USERNAME}@${HOST} "cp ${HOMEDIR}/saufen/app/var/data.db ${HOMEDIR}/backup/data-saufen.db-$(date +\"%Y%m%d%H%M%S\")"
# only keep last 10 backupts
ssh ${USERNAME}@${HOST} "find ${HOMEDIR}/backup/ -type f | sort | head -n -10 | xargs rm -f"
# SCP files to the remote host
rsync -avz --delete deploy/ ${USERNAME}@${HOST}:${TARGETDIR} --exclude=var
# run update script
ssh ${USERNAME}@${HOST} /home/c3h-futtern/saufen/update.sh