ci: update deploy.yaml to deploy dashboard and identity-gateway only

This commit is contained in:
Tiago Yamamoto 2025-12-30 13:33:47 -03:00
parent a52bd4519d
commit 3a236a250a

View file

@ -1,20 +1,17 @@
name: Deploy Stack (Dev)
name: Deploy Core (Dashboard & Identity Gateway)
on:
push:
branches:
- dev
paths:
- 'backend/**'
- 'backoffice/**'
- 'frontend/**'
- 'dashboard/**'
- 'identity-gateway/**'
env:
REGISTRY: rg.fr-par.scw.cloud/funcscwinfrastructureascodehdz4uzhb
NAMESPACE: a5034510-9763-40e8-ac7e-1836e7a61460
REGISTRY: rg.fr-par.scw.cloud/yumi
jobs:
# Job: Deploy no Servidor (Pull das imagens do Scaleway)
deploy-dev:
runs-on: docker
steps:
@ -26,20 +23,15 @@ jobs:
- name: Check changed files
id: check
run: |
if git diff --name-only HEAD~1 HEAD | grep -q "^backend/"; then
echo "backend=true" >> $GITHUB_OUTPUT
if git diff --name-only HEAD~1 HEAD | grep -q "^dashboard/"; then
echo "dashboard=true" >> $GITHUB_OUTPUT
else
echo "backend=false" >> $GITHUB_OUTPUT
echo "dashboard=false" >> $GITHUB_OUTPUT
fi
if git diff --name-only HEAD~1 HEAD | grep -q "^frontend/"; then
echo "frontend=true" >> $GITHUB_OUTPUT
if git diff --name-only HEAD~1 HEAD | grep -q "^identity-gateway/"; then
echo "identity-gateway=true" >> $GITHUB_OUTPUT
else
echo "frontend=false" >> $GITHUB_OUTPUT
fi
if git diff --name-only HEAD~1 HEAD | grep -q "^backoffice/"; then
echo "backoffice=true" >> $GITHUB_OUTPUT
else
echo "backoffice=false" >> $GITHUB_OUTPUT
echo "identity-gateway=false" >> $GITHUB_OUTPUT
fi
- name: Deploy via SSH
@ -53,30 +45,29 @@ jobs:
# Login no Scaleway Registry
echo "${{ secrets.SCW_SECRET_KEY }}" | podman login ${{ env.REGISTRY }} -u nologin --password-stdin
# --- DEPLOY DO BACKEND ---
if [ "${{ steps.check.outputs.backend }}" == "true" ]; then
echo "Pulling e reiniciando Backend..."
podman pull ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/backend:dev-latest
podman tag ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/backend:dev-latest localhost/gohorsejobs-backend-dev:latest
sudo systemctl restart gohorsejobs-backend-dev
# --- DEPLOY DASHBOARD ---
if [ "${{ steps.check.outputs.dashboard }}" == "true" ]; then
echo "🚀 Deploying Dashboard..."
podman pull ${{ env.REGISTRY }}/dashboard:latest
# Stop ancient container if exists
podman stop dashboard || true
podman rm dashboard || true
# Run new container
podman run -d --name dashboard -p 3000:3000 --restart always ${{ env.REGISTRY }}/dashboard:latest
fi
# --- DEPLOY DO FRONTEND ---
if [ "${{ steps.check.outputs.frontend }}" == "true" ]; then
echo "Pulling e reiniciando Frontend..."
podman pull ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/frontend:dev-latest
podman tag ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/frontend:dev-latest localhost/gohorsejobs-frontend-dev:latest
sudo systemctl restart gohorsejobs-frontend-dev
fi
# --- DEPLOY DO BACKOFFICE ---
if [ "${{ steps.check.outputs.backoffice }}" == "true" ]; then
echo "Pulling e reiniciando Backoffice..."
podman pull ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/backoffice:dev-latest
podman tag ${{ env.REGISTRY }}/${{ env.NAMESPACE }}/backoffice:dev-latest localhost/gohorsejobs-backoffice-dev:latest
sudo systemctl restart gohorsejobs-backoffice-dev
# --- DEPLOY IDENTITY GATEWAY ---
if [ "${{ steps.check.outputs.identity-gateway }}" == "true" ]; then
echo "🚀 Deploying Identity Gateway..."
podman pull ${{ env.REGISTRY }}/identity-gateway:latest
# Stop ancient container if exists
podman stop identity-gateway || true
podman rm identity-gateway || true
# Run new container (assuming env from host or .env file mapping needed)
# NOTE: You might need to map .env file: --env-file /path/to/.env
podman run -d --name identity-gateway -p 4000:4000 --restart always ${{ env.REGISTRY }}/identity-gateway:latest
fi
# --- LIMPEZA ---
echo "Limpando imagens antigas..."
echo "🧹 Pruning old images..."
podman image prune -f || true