gohorsejobs/.forgejo/workflows/deploy.yaml
Tiago Yamamoto 632fc78982 feat(ci): add backoffice to deploy pipeline + optimize Dockerfile
- Add backoffice paths trigger to deploy workflow
- Implement conditional builds (only build changed services)
- Optimize Dockerfile with BuildKit cache mounts
- Update pnpm to latest version
- Remove HEALTHCHECK (not supported by Podman OCI format)
2025-12-28 10:47:28 -03:00

71 lines
No EOL
2.3 KiB
YAML

name: Deploy Stack (Dev)
on:
push:
branches:
- dev
paths:
- 'backend/**'
- 'backoffice/**'
jobs:
# Job 1: Testes do Backend (só roda se houver alteração no /backend)
test-backend:
runs-on: docker
if: contains(github.event.head_commit.modified, 'backend/') || contains(github.event.head_commit.added, 'backend/')
steps:
- name: Checkout code
uses: https://github.com/actions/checkout@v4
- name: Setup Go
uses: https://github.com/actions/setup-go@v5
with:
go-version: '1.24'
cache-dependency-path: backend/go.sum
- name: Install dependencies
run: |
cd backend
go mod download
- name: Run tests
run: |
cd backend
go test -v ./internal/services/...
go test -v ./internal/core/usecases/...
# Job 2: Deploy Inteligente
deploy-dev:
runs-on: docker
# O deploy depende dos testes apenas se houver mudanças no backend
needs: [test-backend]
if: always() && (needs.test-backend.result == 'success' || needs.test-backend.result == 'skipped')
steps:
- name: Executar Deploy via SSH na Apolo
uses: https://github.com/appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.PORT || 22 }}
script: |
cd /mnt/data/gohorsejobs
git fetch origin
git checkout dev
git pull origin dev
# DEPLOY DO BACKEND (Se houver alterações)
if git diff --name-only HEAD@{1} HEAD | grep -q "^backend/"; then
echo "Detectadas mudanças no Backend. Iniciando Build..."
podman build -t localhost/gohorsejobs-backend-dev:latest ./backend
sudo systemctl restart gohorsejobs-backend-dev
fi
# DEPLOY DO BACKOFFICE (Se houver alterações)
if git diff --name-only HEAD@{1} HEAD | grep -q "^backoffice/"; then
echo "Detectadas mudanças no Backoffice. Iniciando Build..."
podman build -t localhost/gohorsejobs-backoffice-dev:latest ./backoffice
sudo systemctl restart gohorsejobs-backoffice-dev
fi
podman image prune -f