64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
---
|
|
name: Build and Deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "compose.yaml"
|
|
- "config/**"
|
|
- ".gitea/workflows/build-and-deployment.yaml"
|
|
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 compose file
|
|
run: cp compose.yaml ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Stop containers
|
|
run: docker compose down || true
|
|
working-directory: ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Pull latest images
|
|
run: docker compose pull
|
|
working-directory: ${{ secrets.DEPLOY_PATH }}
|
|
|
|
- name: Start containers with latest image
|
|
run: docker compose up -d --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..."
|
|
# This loop will wait for up to 5 minutes for the container to report a 'healthy' status.
|
|
# It checks the status every 5 seconds. If the container doesn't become healthy
|
|
# within the timeout, the script will exit with an error, failing the workflow.
|
|
end_time=$(( $(date +%s) + 300 )) # 5 minute timeout
|
|
while [ "$(docker inspect -f {{.State.Health.Status}} tor 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 # Print logs for debugging
|
|
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: |
|
|
sleep 5
|
|
docker exec tor cat /app/package.json | grep version || echo "Could not get version"
|