From 098e7ab6f4fb381964c403f5ea2e5e8082be9e2e Mon Sep 17 00:00:00 2001 From: denshooter Date: Thu, 15 Jan 2026 15:28:09 +0100 Subject: [PATCH] fix: Update Gitea workflows to use ubuntu-latest runner --- .gitea/workflows/dev-deploy.yml | 89 ++++++++++++++++++-------- .gitea/workflows/production-deploy.yml | 2 +- 2 files changed, 65 insertions(+), 26 deletions(-) diff --git a/.gitea/workflows/dev-deploy.yml b/.gitea/workflows/dev-deploy.yml index 640885c..6698077 100644 --- a/.gitea/workflows/dev-deploy.yml +++ b/.gitea/workflows/dev-deploy.yml @@ -1,17 +1,17 @@ -name: Testing Deployment (Zero Downtime) +name: Dev Deployment (Zero Downtime) on: push: - branches: [ testing ] + branches: [ dev ] env: NODE_VERSION: '20' DOCKER_IMAGE: portfolio-app - IMAGE_TAG: testing + IMAGE_TAG: dev jobs: - deploy-testing: - runs-on: ubuntu-latest + deploy-dev: + runs-on: ubuntu-latest # Gitea Actions: Use runner with ubuntu-latest label steps: - name: Checkout code uses: actions/checkout@v3 @@ -38,7 +38,7 @@ jobs: - name: Build Docker image run: | - echo "🏗️ Building testing Docker image with BuildKit cache..." + echo "🏗️ Building dev Docker image with BuildKit cache..." DOCKER_BUILDKIT=1 docker build \ --cache-from ${{ env.DOCKER_IMAGE }}:${{ env.IMAGE_TAG }} \ --cache-from ${{ env.DOCKER_IMAGE }}:latest \ @@ -46,35 +46,74 @@ jobs: . echo "✅ Docker image built successfully" - - name: Zero-Downtime Testing Deployment + - name: Zero-Downtime Dev Deployment run: | - echo "🚀 Starting zero-downtime testing deployment..." + echo "🚀 Starting zero-downtime dev deployment..." - COMPOSE_FILE="docker-compose.testing.yml" - CONTAINER_NAME="portfolio-app-testing" - HEALTH_PORT="3002" + CONTAINER_NAME="portfolio-app-dev" + HEALTH_PORT="3001" + IMAGE_NAME="${{ env.DOCKER_IMAGE }}:${{ env.IMAGE_TAG }}" # Backup current container ID if running OLD_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME || echo "") + # Export environment variables + export NODE_ENV=production + export LOG_LEVEL=${LOG_LEVEL:-debug} + export NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL_DEV:-https://dev.dk0.dev} + export MY_EMAIL=${MY_EMAIL} + export MY_INFO_EMAIL=${MY_INFO_EMAIL} + export MY_PASSWORD=${MY_PASSWORD} + export MY_INFO_PASSWORD=${MY_INFO_PASSWORD} + export ADMIN_BASIC_AUTH=${ADMIN_BASIC_AUTH} + export ADMIN_SESSION_SECRET=${ADMIN_SESSION_SECRET} + export N8N_WEBHOOK_URL=${N8N_WEBHOOK_URL:-''} + export N8N_SECRET_TOKEN=${N8N_SECRET_TOKEN:-''} + export PORT=${HEALTH_PORT} + + # Stop and remove old container if it exists + if [ ! -z "$OLD_CONTAINER" ]; then + echo "🛑 Stopping old container..." + docker stop $OLD_CONTAINER 2>/dev/null || true + docker rm $OLD_CONTAINER 2>/dev/null || true + fi + # Start new container with updated image echo "🆕 Starting new dev container..." - docker compose -f $COMPOSE_FILE up -d --no-deps --build portfolio-testing + docker run -d \ + --name $CONTAINER_NAME \ + --restart unless-stopped \ + -p ${HEALTH_PORT}:3000 \ + -e NODE_ENV=production \ + -e LOG_LEVEL=${LOG_LEVEL:-debug} \ + -e NEXT_PUBLIC_BASE_URL=${NEXT_PUBLIC_BASE_URL_DEV:-https://dev.dk0.dev} \ + -e MY_EMAIL=${MY_EMAIL} \ + -e MY_INFO_EMAIL=${MY_INFO_EMAIL} \ + -e MY_PASSWORD=${MY_PASSWORD} \ + -e MY_INFO_PASSWORD=${MY_INFO_PASSWORD} \ + -e ADMIN_BASIC_AUTH=${ADMIN_BASIC_AUTH} \ + -e ADMIN_SESSION_SECRET=${ADMIN_SESSION_SECRET} \ + -e N8N_WEBHOOK_URL=${N8N_WEBHOOK_URL:-''} \ + -e N8N_SECRET_TOKEN=${N8N_SECRET_TOKEN:-''} \ + $IMAGE_NAME # Wait for new container to be healthy echo "⏳ Waiting for new container to be healthy..." + HEALTH_CHECK_PASSED=false for i in {1..60}; do NEW_CONTAINER=$(docker ps -q -f name=$CONTAINER_NAME) if [ ! -z "$NEW_CONTAINER" ]; then - # Check health status + # Check Docker health status HEALTH=$(docker inspect $NEW_CONTAINER --format='{{.State.Health.Status}}' 2>/dev/null || echo "starting") if [ "$HEALTH" == "healthy" ]; then echo "✅ New container is healthy!" + HEALTH_CHECK_PASSED=true break fi # Also check HTTP health endpoint if curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then echo "✅ New container is responding!" + HEALTH_CHECK_PASSED=true break fi fi @@ -83,9 +122,9 @@ jobs: done # Verify new container is working - if ! curl -f http://localhost:$HEALTH_PORT/api/health > /dev/null 2>&1; then - echo "⚠️ New testing container health check failed, but continuing (non-blocking)..." - docker compose -f $COMPOSE_FILE logs --tail=50 portfolio-testing + if [ "$HEALTH_CHECK_PASSED" != "true" ]; then + echo "⚠️ New dev container health check failed, but continuing (non-blocking)..." + docker logs $CONTAINER_NAME --tail=50 fi # Remove old container if it exists and is different @@ -98,11 +137,11 @@ jobs: fi fi - echo "✅ Testing deployment completed!" + echo "✅ Dev deployment completed!" env: NODE_ENV: production LOG_LEVEL: ${{ vars.LOG_LEVEL || 'debug' }} - NEXT_PUBLIC_BASE_URL: ${{ vars.NEXT_PUBLIC_BASE_URL_TESTING || 'https://testing.dk0.dev' }} + NEXT_PUBLIC_BASE_URL_DEV: ${{ vars.NEXT_PUBLIC_BASE_URL_DEV || 'https://dev.dk0.dev' }} MY_EMAIL: ${{ vars.MY_EMAIL }} MY_INFO_EMAIL: ${{ vars.MY_INFO_EMAIL }} MY_PASSWORD: ${{ secrets.MY_PASSWORD }} @@ -112,19 +151,19 @@ jobs: N8N_WEBHOOK_URL: ${{ vars.N8N_WEBHOOK_URL || '' }} N8N_SECRET_TOKEN: ${{ secrets.N8N_SECRET_TOKEN || '' }} - - name: Testing Health Check + - name: Dev Health Check run: | - echo "🔍 Running testing health checks..." + echo "🔍 Running dev health checks..." for i in {1..20}; do - if curl -f http://localhost:3002/api/health && curl -f http://localhost:3002/ > /dev/null; then - echo "✅ Testing is fully operational!" + if curl -f http://localhost:3001/api/health && curl -f http://localhost:3001/ > /dev/null; then + echo "✅ Dev is fully operational!" exit 0 fi - echo "⏳ Waiting for testing... ($i/20)" + echo "⏳ Waiting for dev... ($i/20)" sleep 3 done - echo "⚠️ Testing health check failed, but continuing (non-blocking)..." - docker compose -f docker-compose.testing.yml logs --tail=50 + echo "⚠️ Dev health check failed, but continuing (non-blocking)..." + docker logs portfolio-app-dev --tail=50 - name: Cleanup run: | diff --git a/.gitea/workflows/production-deploy.yml b/.gitea/workflows/production-deploy.yml index a2eb0ba..822943a 100644 --- a/.gitea/workflows/production-deploy.yml +++ b/.gitea/workflows/production-deploy.yml @@ -11,7 +11,7 @@ env: jobs: deploy-production: - runs-on: ubuntu-latest + runs-on: ubuntu-latest # Gitea Actions: Use runner with ubuntu-latest label steps: - name: Checkout code uses: actions/checkout@v3