Each CI step runs in a separate container (node:18-bullseye). Docker CLI must be installed within that container to use docker-compose.
74 lines
1.9 KiB
YAML
74 lines
1.9 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
# Triggers: push to main and pull requests to main
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
# Backend build job
|
|
backend-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET 10
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 10.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore Backend/PruebaGentle.slnx
|
|
|
|
- name: Build backend
|
|
run: dotnet build Backend/PruebaGentle.slnx --configuration Release
|
|
|
|
# Frontend build job
|
|
frontend-build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js 22
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22.x
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: Frontend
|
|
|
|
- name: Build frontend
|
|
run: npm run build
|
|
working-directory: Frontend
|
|
|
|
- name: Run tests
|
|
run: npm run test:run
|
|
working-directory: Frontend
|
|
|
|
# Docker build job (depends on backend and frontend builds)
|
|
docker-build:
|
|
needs: [backend-build, frontend-build]
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/main'
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Docker CLI
|
|
run: |
|
|
curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-24.0.7.tgz -o /tmp/docker.tgz
|
|
tar -xzf /tmp/docker.tgz -C /tmp
|
|
cp /tmp/docker/docker /usr/local/bin/
|
|
chmod +x /usr/local/bin/docker
|
|
curl -fsSL "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
|
chmod +x /usr/local/bin/docker-compose
|
|
|
|
- name: Build Docker images
|
|
run: docker-compose build |