-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (98 loc) · 3.64 KB
/
Copy pathci.yml
File metadata and controls
118 lines (98 loc) · 3.64 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# ==============================================================
# CI/CD Pipeline — ComputerStore Microservices
# Triggers on push/PR to main branch
# ==============================================================
name: ComputerStore CI/CD Pipeline
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
# ── Stage 1: Build & Test ──
build-and-test:
name: Build & Test All Microservices
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ComputerStore
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build all modules
run: ./mvnw clean compile -DskipTests --batch-mode
- name: Run unit tests
run: ./mvnw test --batch-mode -pl store-service,user-service
- name: Generate JaCoCo coverage report
run: ./mvnw jacoco:report --batch-mode -pl store-service
if: always()
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: jacoco-coverage-report
path: ComputerStore/store-service/target/site/jacoco/
retention-days: 14
- name: Package all modules (create JARs)
run: ./mvnw package -DskipTests --batch-mode
# ── Stage 2: Docker Build ──
docker-build:
name: Build Docker Images
runs-on: ubuntu-latest
needs: build-and-test
defaults:
run:
working-directory: ./ComputerStore
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Package all modules
run: ./mvnw package -DskipTests --batch-mode
- name: Build Docker images
run: |
docker build -t computerstore/config-server:latest ./config-server
docker build -t computerstore/discovery-server:latest ./discovery-server
docker build -t computerstore/api-gateway:latest ./api-gateway
docker build -t computerstore/store-service:latest ./store-service
docker build -t computerstore/user-service:latest ./user-service
docker build -t computerstore/notification-service:latest ./notification-service
- name: List Docker images
run: docker images | grep computerstore
# ── Stage 3: Deploy to Staging (simulated) ──
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
needs: docker-build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
defaults:
run:
working-directory: ./ComputerStore
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Simulate staging deployment
run: |
echo "============================================="
echo " Deploying ComputerStore to Staging..."
echo "============================================="
echo "Config Server → staging:8888"
echo "Discovery Server → staging:8761"
echo "API Gateway → staging:8443"
echo "Store Service → staging:8081"
echo "User Service → staging:8082"
echo "Notification Service → staging:8084"
echo "============================================="
echo " Deployment completed successfully!"
echo "============================================="