Despliegue del Frontend de Angular
7. Crear GitHub Actions
Crear GitHub Actions para compilar y subir el dist
Creamos el archivo: .github/workflows/deploy.yml
name: Deploy Angular to VPS (Apache)
on:
push:
branches: [ "main" ]
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm ci
- run: npm run build -- --configuration production
- name: Inspect dist
run: |
ls -la dist
ls -la dist/* || true
ls -la dist/*/browser || true
# AJUSTA EL path cuando veas la estructura en logs
- name: Deploy via rsync
uses: burnett01/rsync-deployments@7.0.1
with:
switches: -avzr --delete
path: dist/posts-get/browser/
remote_path: ${{ secrets.VPS_PATH }}
remote_host: ${{ secrets.VPS_HOST }}
remote_user: ${{ secrets.VPS_USER }}
remote_key: ${{ secrets.VPS_SSH_KEY }}
El despliegue copia únicamente el contenido de la carpeta browser, ya que contiene directamente el index.html que Apache sirve desde /var/www/html.