conocimientocicd-architecttemplates/8012 B
cd.fase2.vue.yml.template
Fichero que /hv:cicd-architect usa o materializa en el proyecto. Se muestra tal cual está en el plugin.
# =============================================================================
# {{PROYECTO_NOMBRE}} — Workflow CD {{PIPELINE_NAME}} (Fase 2, stack Vue 3 + Vite + TypeScript)
# Ovillo cicd-architect github-vue @ {{TEMPLATE_STAMP}} (sello de plantilla; /cicd-status detecta drift)
# Reglas: cicd-runtime G1-G19. Smoke BEST-EFFORT (G14: una SPA no expone /health; el deploy real ya lo verifico
# la herramienta de publicacion). Sin Hub/QR (G7 solo aplica a .NET).
# Materializado por /cicd-init en .github/workflows/cd-{{SLUG}}.yml. Para Fase 1 (CI-only) /cicd-init deja solo
# el job `build` y lo llama ci.yml.
#
# MODELO DE DEPLOY: ON-DEMAND (ver cd.fase2.dotnet.yml.template para AUTO y BRANCH-GATED).
# RAMAS CONDICIONALES: sin `lint` en package.json -> quitar el step Lint; sin @vitest/coverage-v8 -> Test sin --coverage.
# =============================================================================
name: CD {{PIPELINE_NAME}}
on:
push:
branches:
- '{{RAMA_BASE}}'
# {{TRIGGER_BRANCHES_EXTRA}} <- /cicd-init anade aqui "- 'develop'" en el modelo branch-gated
paths:
- '{{ENTRYPOINT_PATH}}/**'
- '.github/workflows/cd-{{SLUG}}.yml'
- '.github/actions/**'
pull_request:
branches: ['{{RAMA_BASE}}']
paths:
- '{{ENTRYPOINT_PATH}}/**'
merge_group:
branches: ['{{RAMA_BASE}}']
workflow_dispatch:
inputs:
environment:
description: 'Entorno a desplegar (G1 on-demand: el push solo construye)'
type: choice
required: true
options: [dev, pre, pro]
permissions:
contents: read
concurrency:
group: cd-{{SLUG}}-${{ github.ref }}
cancel-in-progress: false
defaults:
run:
working-directory: '{{ENTRYPOINT_PATH}}'
jobs:
build:
name: Build
runs-on: '{{RUNNER}}'
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: '{{NODE_VERSION}}'
cache: npm
cache-dependency-path: '{{ENTRYPOINT_PATH}}/package-lock.json'
- name: Install (lockfile)
run: npm ci
- name: Lint
run: npm run lint --if-present
- name: Test
run: npm test -- --run --coverage
- name: Build
run: npm run build
- name: Security scan (G8, npm audit; no tumba el build)
if: always()
uses: ./.github/actions/security-scan
with:
stack: spa
working-dir: '{{ENTRYPOINT_PATH}}'
- name: Upload dist
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist-{{SLUG}}-${{ github.sha }}
path: '{{ENTRYPOINT_PATH}}/dist'
retention-days: 30
deploy-dev:
name: Deploy dev
runs-on: '{{RUNNER}}'
needs: build
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'dev'
timeout-minutes: 15
environment:
name: dev
url: '{{DEV_URL}}'
permissions:
contents: read
id-token: write
steps:
- name: Checkout (solo .github/actions)
# Las composite actions locales exigen el repo en disco; sparse checkout de .github/actions para no romper G4:
# el codigo NO se despliega desde el checkout, la unica fuente del deploy es el artefacto descargado.
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/actions
- name: Download dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist-{{SLUG}}-${{ github.sha }}
path: ./dist
- name: Security gate (G8, warn)
uses: ./.github/actions/security-gate
with:
mode: warn
gate-severity: High
# {{DEPLOY_STEP}}
- name: Deploy
working-directory: .
run: |
echo "::error::Paso de despliegue sin configurar para dev (sustituir {{DEPLOY_STEP}} en /cicd-init)"
exit 1
- name: Smoke test (G14, best-effort)
working-directory: .
shell: bash
run: |
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 "{{DEV_URL}}/" || true)
if [ "$code" = "200" ]; then echo "GET / OK"; else echo "::warning::Smoke best-effort: HTTP $code contra {{DEV_URL}}/ (hairpin NAT o SNI); el deploy ya lo verifico la herramienta de publicacion"; fi
deploy-pre:
name: Deploy pre
runs-on: '{{RUNNER}}'
needs: build
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'pre'
timeout-minutes: 15
environment:
name: pre
url: '{{DEMO_URL}}'
permissions:
contents: read
id-token: write
steps:
- name: Checkout (solo .github/actions)
# Las composite actions locales exigen el repo en disco; sparse checkout de .github/actions para no romper G4:
# el codigo NO se despliega desde el checkout, la unica fuente del deploy es el artefacto descargado.
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/actions
- name: Download dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist-{{SLUG}}-${{ github.sha }}
path: ./dist
- name: Security gate (G8, block)
uses: ./.github/actions/security-gate
with:
mode: block
gate-severity: High
# {{DEPLOY_STEP}}
- name: Deploy
working-directory: .
run: |
echo "::error::Paso de despliegue sin configurar para pre (sustituir {{DEPLOY_STEP}} en /cicd-init)"
exit 1
- name: Smoke test (G14, best-effort)
working-directory: .
shell: bash
run: |
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 "{{DEMO_URL}}/" || true)
if [ "$code" = "200" ]; then echo "GET / OK"; else echo "::warning::Smoke best-effort: HTTP $code contra {{DEMO_URL}}/"; fi
deploy-pro:
name: Deploy pro
runs-on: '{{RUNNER}}'
needs: build
if: github.event_name == 'workflow_dispatch' && inputs.environment == 'pro'
timeout-minutes: 20
environment:
name: pro
url: '{{PROD_URL}}'
permissions:
contents: read
id-token: write
steps:
- name: Checkout (solo .github/actions)
# Las composite actions locales exigen el repo en disco; sparse checkout de .github/actions para no romper G4:
# el codigo NO se despliega desde el checkout, la unica fuente del deploy es el artefacto descargado.
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: .github/actions
- name: Download dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist-{{SLUG}}-${{ github.sha }}
path: ./dist
- name: Security gate (G8, block)
uses: ./.github/actions/security-gate
with:
mode: block
gate-severity: High
# {{DEPLOY_STEP}} — con backup previo del directorio publicado (G9 capa 1)
- name: Deploy
working-directory: .
run: |
echo "::error::Paso de despliegue sin configurar para pro (sustituir {{DEPLOY_STEP}} en /cicd-init)"
exit 1
- name: Smoke test (G14, best-effort)
working-directory: .
shell: bash
run: |
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 15 "{{PROD_URL}}/" || true)
if [ "$code" = "200" ]; then echo "GET / OK"; else echo "::warning::Smoke best-effort: HTTP $code contra {{PROD_URL}}/. Si la app no responde, rollback: gh workflow run cd-{{SLUG}}.yml --ref <sha_anterior> -f environment=pro"; fi