2024-06-22 19:47:23 +00:00
|
|
|
on:
|
|
|
|
release
|
|
|
|
jobs:
|
|
|
|
ls:
|
|
|
|
runs-on: docker
|
|
|
|
container:
|
2024-12-18 13:30:24 +00:00
|
|
|
image: git.php.fail/lubiana/container/php:8.4.1-ci
|
2024-06-22 19:47:23 +00:00
|
|
|
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 }}
|
2024-06-22 20:20:51 +00:00
|
|
|
- name: prepare deploy
|
|
|
|
run: sh ./deploy/prepare-deploy.sh
|
2024-06-23 09:58:18 +00:00
|
|
|
- name: deploy
|
|
|
|
env:
|
|
|
|
HOST: 'web.server.c3h'
|
|
|
|
USERNAME: 'c3h-futtern'
|
|
|
|
TARGETDIR: '/home/c3h-futtern/futtern'
|
2024-06-30 08:53:10 +00:00
|
|
|
HOMEDIR: '/home/c3h-futtern'
|
2024-06-23 09:58:18 +00:00
|
|
|
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
|
2024-06-30 08:18:24 +00:00
|
|
|
# backup database
|
2024-06-30 08:53:10 +00:00
|
|
|
ssh ${USERNAME}@${HOST} "cp ${HOMEDIR}/futtern/app/var/data.db ${HOMEDIR}/backup/data.db-$(date +\"%Y%m%d%H%M%S\")"
|
2024-06-30 08:18:24 +00:00
|
|
|
# only keep last 10 backupts
|
2024-06-30 08:53:10 +00:00
|
|
|
ssh ${USERNAME}@${HOST} "find ${HOMEDIR}/backup/ -type f | sort | head -n -10 | xargs rm -f"
|
2024-06-23 09:58:18 +00:00
|
|
|
# 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
|
|
|
|
|
2024-06-22 20:20:51 +00:00
|
|
|
|
2024-06-23 09:58:18 +00:00
|
|
|
|
2024-06-22 20:20:51 +00:00
|
|
|
|