name: Build y Deploy a Producción on: push: branches: [main] jobs: build: name: Construir y Subir Imágenes Docker runs-on: sh-runner steps: # --- ¡PASO #1! --- # Primero, clonamos el código. - name: Checkout del código uses: actions/checkout@v4 # --- PASO #2: Login --- - name: Login al Registro de Gitea uses: docker/login-action@v3 with: registry: gitea:5000 username: ${{ gitea.actor }} password: ${{ secrets.ACTIONS_PAT }} # --- PASO #3: Build Backend --- - name: Construir y Subir API Backend uses: docker/build-push-action@v5 with: context: . file: ./Backend/GestionIntegral.Api/Dockerfile push: true tags: gitea:5000/${{ gitea.repository }}/api:latest # --- PASO #4: Build Frontend --- - name: Construir y Subir Frontend uses: docker/build-push-action@v5 with: context: ./Frontend file: ./Frontend/Dockerfile push: true # El tag del frontend debe ser 'frontend', no 'api' tags: gitea:5000/${{ gitea.repository }}/frontend:latest deploy: name: Desplegar a Producción runs-on: sh-runner needs: build steps: - name: Desplegar con Docker Compose uses: appleboy/ssh-action@master with: host: ${{ secrets.PROD_SERVER_HOST }} username: ${{ secrets.PROD_SERVER_USER }} key: ${{ secrets.PROD_SERVER_SSH_KEY }} script: | cd /opt/gestion-integral export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD }}' export JWT_KEY='${{ secrets.JWT_SECRET_KEY }}' # Login con la IP pública (desde el servidor de prod) docker login ${{ secrets.REGISTRY_URL }} -u ${{ gitea.actor }} -p ${{ secrets.ACTIONS_PAT }} docker compose pull docker compose up -d docker image prune -af