1+ name : CI Pipeline
2+
3+ on :
4+ push :
5+ branches : [ main, develop ]
6+ pull_request :
7+ branches : [ main, develop ]
8+
9+ jobs :
10+ backend-test :
11+ name : Backend Tests
12+ runs-on : ubuntu-latest
13+
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ - name : Set up JDK 21
18+ uses : actions/setup-java@v4
19+ with :
20+ java-version : ' 21'
21+ distribution : ' temurin'
22+ cache : maven
23+
24+ - name : Run Backend Tests
25+ run : ./mvnw test
26+
27+ - name : Upload Test Results
28+ if : always()
29+ uses : actions/upload-artifact@v4
30+ with :
31+ name : backend-test-results
32+ path : target/surefire-reports/
33+
34+ frontend-build :
35+ name : Frontend Build
36+ runs-on : ubuntu-latest
37+
38+ steps :
39+ - uses : actions/checkout@v4
40+
41+ - name : Set up Node.js
42+ uses : actions/setup-node@v4
43+ with :
44+ node-version : ' 20'
45+ cache : ' npm'
46+ cache-dependency-path : frontend/package-lock.json
47+
48+ - name : Install Dependencies
49+ working-directory : ./frontend
50+ run : npm ci
51+
52+ - name : Build Frontend
53+ working-directory : ./frontend
54+ run : npm run build
55+
56+ - name : Upload Build Artifacts
57+ uses : actions/upload-artifact@v4
58+ with :
59+ name : frontend-build
60+ path : src/main/resources/static/
61+
62+ docker-build :
63+ name : Docker Build Test
64+ runs-on : ubuntu-latest
65+ needs : [backend-test, frontend-build]
66+
67+ steps :
68+ - uses : actions/checkout@v4
69+
70+ - name : Set up Docker Buildx
71+ uses : docker/setup-buildx-action@v3
72+
73+ - name : Build Docker Image
74+ uses : docker/build-push-action@v5
75+ with :
76+ context : .
77+ file : ./Dockerfile
78+ push : false
79+ load : true
80+ tags : website:ci-test
81+ cache-from : type=gha
82+ cache-to : type=gha,mode=max
83+
84+ - name : Test Docker Image
85+ run : |
86+ docker run -d -p 8080:8080 --name test-app website:ci-test
87+ sleep 30
88+ curl -f http://localhost:8080/api/client/info || exit 1
89+ docker stop test-app
90+ docker rm test-app
0 commit comments