Skip to content

Update CI-CD-Pipeline.yml #5

Update CI-CD-Pipeline.yml

Update CI-CD-Pipeline.yml #5

name: CI Pipeline with Docker Compose
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
build-test-run:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker and Docker Compose
uses: docker/setup-buildx-action@v2
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Set up environment file (.env)
run: |
echo "APPLICATION_PORT=8080" >> .env
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env
echo "DATABASE_URL=jdbc:postgresql://localhost:5432/auth" >> .env
echo "DATABASE_USERNAME=${{ secrets.DATABASE_USERNAME }}" >> .env
echo "EMAIL_SERVICE_NAME=NODEJS-MAIL-SERVICE" >> .env
echo "EUREKA_ENABLED=false" >> .env
- name: Start required services with Docker Compose
run: docker-compose up -d
- name: Wait for Database to Be Ready
run: sleep 10 # Adjust based on your database startup time
- name: Build and Test the Application
run: |
mvn clean install -DskipTests
mvn test
- name: Run the Application
env:
APPLICATION_PORT: 8080
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_URL: jdbc:postgresql://localhost:5432/auth
DATABASE_USERNAME: ${{ secrets.DATABASE_USERNAME }}
run: mvn spring-boot:run &
- name: Verify Application is Running
run: sleep 10 # Adjust to give the application time to start
- name: Stop the Application
run: pkill -f 'spring-boot:run'
- name: Tear Down Docker Services
run: docker-compose down