Create ci.yml #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI Pipeline | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
services: | ||
redis: | ||
image: docker.io/redis:7.0-alpine | ||
options: --health-cmd="redis-cli ping" --health-interval=5s --health-timeout=5s --health-retries=5 | ||
ports: | ||
- 6379:6379 | ||
db: | ||
image: groonga/pgroonga:latest | ||
options: --health-cmd="pg_isready --user=\$POSTGRES_USER --dbname=\$POSTGRES_DB" --health-interval=5s --health-timeout=5s --health-retries=5 | ||
env: | ||
POSTGRES_USER: example_user | ||
POSTGRES_DB: example_db | ||
ports: | ||
- 5432:5432 | ||
volumes: | ||
- db_data:/var/lib/postgresql/data | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Copy example configuration files | ||
run: | | ||
cp docker-compose.example.yml docker-compose.yml | ||
cp .config/example.yml .config/default.yml | ||
cp .config/docker_example.env .config/docker.env | ||
- name: Pull and run Docker Compose | ||
run: | | ||
docker-compose -f docker-compose.yml up -d # Levanta los servicios usando la imagen de Docker Hub. | ||
- name: Run tests (si tienes alguna prueba) | ||
run: | | ||
# AquΓ agregas los comandos necesarios para tus pruebas, por ejemplo, si usas Jest o Mocha: | ||
docker-compose exec web npm run test | ||
- name: Shutdown Docker Compose | ||
run: docker-compose down | ||
volumes: | ||
db_data: |