name: Build Docker Image (No Push)

on:
  push:
    branches-ignore:
      - development
      - latest

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout del código
        uses: actions/checkout@v6
      - name: Configurar Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.14'
      - name: Instalar dependencias
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Ejecutar tests
        env:
          DJANGO_SETTINGS_MODULE: proyecto.settings
        run: |
          python manage.py test

  docker:
    runs-on: ubuntu-latest
    needs: test
    permissions:
      contents: read

    steps:
      - name: Checkout del código
        uses: actions/checkout@v6

      - name: Configurar Docker Buildx
        uses: docker/setup-buildx-action@v4

      - name: Build (sin push)
        uses: docker/build-push-action@v6
        with:
          context: .
          push: false
