gamesshop/.forgejo/workflows/deploy.yml

32 lines
1,000 B
YAML
Raw Normal View History

2024-11-07 17:28:45 +00:00
on:
2024-11-05 19:06:35 +00:00
push:
branches:
- 'master'
jobs:
build:
2024-11-05 19:25:44 +00:00
runs-on:
- kiljho
2024-11-07 17:30:06 +00:00
container:
image: git.php.fail/lubiana/container/php:ci
2024-11-05 19:06:35 +00:00
steps:
2024-11-07 17:28:45 +00:00
- name: Update Service
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }}
2024-11-07 17:33:38 +00:00
HOST: 'docker.host'
2024-11-07 17:28:45 +00:00
USERNAME: 'michel'
TARGETDIR: '/mnt/drive/containers/gamesshop'
run: |
2024-11-07 17:33:38 +00:00
ping ${HOST}
2024-11-07 17:28:45 +00:00
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
ssh ${USERNAME}@${HOST} "cd ${TARGETDIR} && git reset --hard origin/master && sudo ${TARGETDIR}/deploy/deploy.sh"
# Start service
ssh ${USERNAME}@${HOST} "cd ${TARGETDIR}/deploy && sudo docker compose up -d"