gamesshop/.forgejo/workflows/deploy.yml

30 lines
983 B
YAML
Raw Normal View History

2024-11-07 18:28:45 +01:00
on:
2024-11-05 20:06:35 +01:00
push:
branches:
- 'master'
jobs:
build:
2024-11-05 20:25:44 +01:00
runs-on:
- kiljho
2024-11-07 18:30:06 +01:00
container:
image: git.php.fail/lubiana/container/php:ci
2024-11-05 20:06:35 +01:00
steps:
2024-11-07 18:28:45 +01:00
- name: Update Service
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
2024-11-07 18:35:43 +01:00
HOST: '172.19.0.1'
2024-11-07 18:28:45 +01:00
USERNAME: 'michel'
TARGETDIR: '/mnt/drive/containers/gamesshop'
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H $HOST >> ~/.ssh/known_hosts
# Stop service
ssh ${USERNAME}@${HOST} "cd ${TARGETDIR}/deploy && sudo docker compose down -v"
# Update Service
2024-11-07 18:38:11 +01:00
ssh ${USERNAME}@${HOST} "cd ${TARGETDIR} && git fetch && git reset --hard origin/master && sudo bash ${TARGETDIR}/deploy/deploy.sh"
2024-11-07 18:28:45 +01:00
# Start service
ssh ${USERNAME}@${HOST} "cd ${TARGETDIR}/deploy && sudo docker compose up -d"