62 lines
1.8 KiB
YAML
62 lines
1.8 KiB
YAML
---
|
|
name: Build and Deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "compose.yaml"
|
|
- "config/**"
|
|
- ".gitea/workflows/build-and-deployment.yaml"
|
|
- "Dockerfile"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: proxmox
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Ensure directory exists
|
|
run: |
|
|
mkdir -p ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Copy project files
|
|
run: |
|
|
cp compose.yaml ${{ secrets.DEPLOY_PATH }}
|
|
cp Dockerfile ${{ secrets.DEPLOY_PATH }}
|
|
# Kopiert das config Verzeichnis, falls es existiert
|
|
if [ -d "config" ]; then
|
|
cp -r config ${{ secrets.DEPLOY_PATH }}
|
|
fi
|
|
|
|
- name: Stop containers
|
|
run: docker compose down || true
|
|
working-directory: ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Build and start containers
|
|
run: docker compose up -d --build --force-recreate
|
|
working-directory: ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Check running containers
|
|
run: docker ps
|
|
|
|
- name: Wait for container to be healthy
|
|
run: |
|
|
echo "Waiting for container to become healthy..."
|
|
end_time=$(( $(date +%s) + 300 )) # 5 minute timeout
|
|
while [ "$(docker inspect -f {{.State.Health.Status}} tor-proxy 2>/dev/null || echo 'unhealthy')" != "healthy" ]; do
|
|
if [ $(date +%s) -gt $end_time ]; then
|
|
echo "Timeout: Container did not become healthy within 5 minutes."
|
|
docker logs tor-proxy
|
|
exit 1
|
|
fi
|
|
sleep 5
|
|
echo "Container not healthy yet. Retrying in 5 seconds..."
|
|
done
|
|
echo "Container is healthy! Proceeding with next step."
|
|
|
|
- name: Show tor version
|
|
run: docker exec tor-proxy tor --version || echo "Could not get version"
|