-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (32 loc) · 1.07 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Configure SSH known_hosts
run: |
ssh-keyscan -H ${{ secrets.HETZNER_IP }} >> ~/.ssh/known_hosts
- name: Deploy using Docker Compose
env:
DOCKER_HOST: ssh://root@${{ secrets.HETZNER_IP }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
run: |
if docker ps -a --format '{{.Names}}' | grep -Eq '^redis$'; then
echo "Removing existing 'redis' container..."
docker rm -f redis
else
echo "'redis' container does not exist. No action needed."
fi
docker system prune --all --force
docker compose --file compose.yaml --file cloudflare.yaml --file logging.yaml up --build --force-recreate --detach