-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (55 loc) · 1.95 KB
/
CI-CD-Pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- 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
- name: Build and Test the Application
run: |
mvn 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