Skip to content
Merged

Dev #19

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI Pipeline

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:

env:
Expand All @@ -23,30 +23,33 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Build images defined in docker-compose (backend + frontend)
- name: Build containers
run: docker compose -f docker-compose.yml build

- name: Start Postgres and Redis in background
# Start only infra services
- name: Start Postgres and Redis
run: docker compose -f docker-compose.yml up -d postgres redis

- name: Wait for Postgres to be ready
- name: Wait for Postgres
run: |
echo "Esperando a que Postgres inicie..."
echo "Esperando Postgres..."
timeout 60 bash -c 'until docker compose exec -T postgres pg_isready -U postgres -d db_task_manager; do sleep 2; done'
echo "¡Postgres está listo!"
echo "Postgres listo"

- name: Wait for Redis to be ready
- name: Wait for Redis
run: |
echo "Esperando a que Redis inicie..."
echo "Esperando Redis..."
timeout 30 bash -c 'until docker compose exec -T redis redis-cli ping | grep -q PONG; do sleep 1; done'
echo "¡Redis está listo!"
echo "Redis listo"

# Run NestJS tests
- name: Run NestJS tests
run: docker compose -f docker-compose.yml run --rm nestjs yarn test

Expand All @@ -60,7 +63,7 @@ jobs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- name: Check out the repository
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
Expand All @@ -72,11 +75,24 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# 🔥 Backend (NestJS)
- name: Build and push NestJS image
uses: docker/build-push-action@v5
with:
context: .
context: ./backend
file: ./backend/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/task-manager:latest
${{ secrets.DOCKERHUB_USERNAME }}/task-manager:${{ github.sha }}
${{ secrets.DOCKERHUB_USERNAME }}/task-manager-backend:latest
${{ secrets.DOCKERHUB_USERNAME }}/task-manager-backend:${{ github.sha }}

# 🔵 Frontend (Next.js) – opcional
- name: Build and push NextJS image
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/task-manager-frontend:latest
${{ secrets.DOCKERHUB_USERNAME }}/task-manager-frontend:${{ github.sha }}