feat: clean ci
Laravel CI-CD / Tests Unitaires (push) Successful in 21s Details
Laravel CI-CD / Build & Push Docker (push) Successful in 45s Details
Laravel CI-CD / Deploy (push) Successful in 7s Details

This commit is contained in:
Leon Morival 2026-05-19 16:55:50 +02:00
parent 1259ebc3a9
commit f8e1e89a83
1 changed files with 13 additions and 56 deletions

View File

@ -60,26 +60,14 @@ jobs:
docker push "$IMAGE:latest"
# =========================
# DEPLOY BLUE / GREEN (CADDY GÈRE LE ROUTING)
# DEPLOY (SIMPLE)
# =========================
deploy:
name: Deploy Blue/Green (Caddy routing)
name: Deploy
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout deploy files
uses: actions/checkout@v4
- name: Upload docker-compose
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: docker-compose.prod.yml
target: /opt/bemeal
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
env:
@ -95,54 +83,23 @@ jobs:
set -eu
APP_DIR="/opt/bemeal"
cd "$APP_DIR"
COMPOSE="docker compose \
--project-directory $APP_DIR \
--env-file $APP_DIR/.env.prod \
-f $APP_DIR/docker-compose.prod.yml"
IMAGE="$REGISTRY/$IMAGE_NAME:$IMAGE_TAG"
echo "Pull image"
docker pull "$IMAGE"
echo "Deploy shared infra"
echo "Start infra services"
$COMPOSE up -d pgsql redis meilisearch
# detect active
ACTIVE=""
if docker ps | grep -q bemeal-api-blue && \
[ "$(docker inspect -f '{{.State.Health.Status}}' bemeal-api-blue 2>/dev/null || true)" = "healthy" ]; then
ACTIVE=blue
fi
echo "Deploy API (blue/green handled by Caddy)"
IMAGE="$IMAGE" $COMPOSE up -d --no-deps --force-recreate bemeal-api-blue
IMAGE="$IMAGE" $COMPOSE up -d --no-deps --force-recreate bemeal-api-green
if docker ps | grep -q bemeal-api-green && \
[ "$(docker inspect -f '{{.State.Health.Status}}' bemeal-api-green 2>/dev/null || true)" = "healthy" ]; then
ACTIVE=green
fi
if [ "$ACTIVE" = "blue" ]; then
TARGET=green
else
TARGET=blue
fi
TARGET_SERVICE="bemeal-api-$TARGET"
echo "Deploy $TARGET_SERVICE"
IMAGE="$IMAGE" $COMPOSE up -d --no-deps --force-recreate "$TARGET_SERVICE"
# wait health
for i in $(seq 1 60); do
STATUS=$(docker inspect -f '{{.State.Health.Status}}' "$TARGET_SERVICE" || true)
[ "$STATUS" = "healthy" ] && break
sleep 2
done
[ "$STATUS" != "healthy" ] && exit 1
# 👉 SWITCH ULTRA SIMPLE
echo "bemeal-api-$TARGET" > /opt/caddy/active
docker exec caddy caddy reload
echo "Deployment done"