59 lines
1.8 KiB
YAML
59 lines
1.8 KiB
YAML
name: Build y Deploy a Producción
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout del código
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Login al Registro de Gitea
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.REGISTRY_URL }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.ACTIONS_PAT }}
|
|
|
|
- name: Construir y Subir API Backend
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./Backend/GestionIntegral.Api/Dockerfile
|
|
push: true
|
|
tags: ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/api:latest
|
|
|
|
- name: Construir y Subir Frontend
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./Frontend
|
|
file: ./Frontend/Dockerfile
|
|
push: true
|
|
tags: ${{ secrets.REGISTRY_URL }}/${{ gitea.repository }}/frontend:latest
|
|
|
|
deploy:
|
|
name: Desplegar a Producción
|
|
runs-on: ubuntu-latest
|
|
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 |