bug fixed #9
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/CD Backend | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
mysql: | |
image: mysql:8.0.31 | |
env: | |
MYSQL_ROOT_PASSWORD: 12345678 | |
MYSQL_DATABASE: tfgdb | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=15s --health-timeout=10s --health-retries=5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Download wait-for-it | |
run: | | |
wget https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O ./Backend/wait-for-it.sh | |
chmod +x ./Backend/wait-for-it.sh | |
- name: Build and Test with Maven | |
run: | | |
cd ./Backend | |
# Espera a que MySQL esté listo | |
echo "--- Waiting for MySQL to be ready ---" | |
./wait-for-it.sh mysql:3306 -t 60 | |
# Ejecutar Maven | |
mvn clean install -DskipTests | |
mvn test -Dspring.profiles.active=test | |
- name: Dockerize application | |
run: | | |
docker build -t jesussmariscal/reurjc -f ./Docker/App/Dockerfile . | |
cd ./Docker/App | |
docker-compose -p myurjc up -d | |
- name: Stop Docker Compose | |
if: always() | |
run: | | |
cd ./Docker/App | |
docker-compose -p myurjc down |