Reversión 3
This commit is contained in:
@@ -1,17 +1,29 @@
|
|||||||
name: Build y Deploy a Producción
|
name: Build y Deploy a Producción
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
name: Construir y Subir Imágenes Docker
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
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
|
- name: Login al Registro de Gitea
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: gitea:5000
|
registry: gitea:5000
|
||||||
username: ${{ gitea.actor }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.ACTIONS_PAT }}
|
password: ${{ secrets.ACTIONS_PAT }}
|
||||||
|
|
||||||
|
# --- PASO #3: Build Backend ---
|
||||||
- name: Construir y Subir API Backend
|
- name: Construir y Subir API Backend
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
@@ -19,13 +31,16 @@ jobs:
|
|||||||
file: ./Backend/GestionIntegral.Api/Dockerfile
|
file: ./Backend/GestionIntegral.Api/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: gitea:5000/${{ gitea.repository }}/api:latest
|
tags: gitea:5000/${{ gitea.repository }}/api:latest
|
||||||
|
|
||||||
|
# --- PASO #4: Build Frontend ---
|
||||||
- name: Construir y Subir Frontend
|
- name: Construir y Subir Frontend
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: ./Frontend
|
||||||
file: ./Frontend/Dockerfile
|
file: ./Frontend/Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: gitea:5000/${{ gitea.repository }}/api:latest
|
# El tag del frontend debe ser 'frontend', no 'api'
|
||||||
|
tags: gitea:5000/${{ gitea.repository }}/frontend:latest
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: Desplegar a Producción
|
name: Desplegar a Producción
|
||||||
@@ -42,19 +57,12 @@ jobs:
|
|||||||
script: |
|
script: |
|
||||||
cd /opt/gestion-integral
|
cd /opt/gestion-integral
|
||||||
|
|
||||||
# Pasamos los secretos como variables de entorno
|
|
||||||
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD }}'
|
export DB_SA_PASSWORD='${{ secrets.DB_SA_PASSWORD }}'
|
||||||
export JWT_KEY='${{ secrets.JWT_SECRET_KEY }}'
|
export JWT_KEY='${{ secrets.JWT_SECRET_KEY }}'
|
||||||
|
|
||||||
# Login al registro de Gitea DENTRO del servidor de producción
|
# Login con la IP pública (desde el servidor de prod)
|
||||||
# Aquí también usamos el ACTIONS_PAT
|
docker login ${{ secrets.REGISTRY_URL }} -u ${{ gitea.actor }} -p ${{ secrets.ACTIONS_PAT }}
|
||||||
docker login ${{ gitea:5000 }} -u ${{ gitea.actor }} -p ${{ secrets.ACTIONS_PAT }}
|
|
||||||
|
|
||||||
# Descargamos las nuevas versiones de las imágenes
|
|
||||||
docker compose pull
|
docker compose pull
|
||||||
|
|
||||||
# Levantamos el stack con los cambios
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
# Limpiamos imágenes viejas que ya no se usan
|
|
||||||
docker image prune -af
|
docker image prune -af
|
||||||
Reference in New Issue
Block a user