name: Build and Deploy (Gitea)

on:
  push:
    branches: [ main ]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Build Manager
        run: |
          cd manager
          docker build --no-cache -t edumanager:local .
          
      - name: Build Portal
        run: |
          cd portal
          docker build --no-cache -t portalaluno:local .

      - name: Deploy to Portainer
        run: |
          docker service update --force --image edumanager:local edumanager-v2_edumanager
          docker service update --force --image portalaluno:local edumanager-v2_portalaluno
