Skip to content

Commit 095f892

Browse files
Merge pull request #44 from AET-DevOps25/feature/testing-and-ci-pipeline
Feature/testing and ci pipeline
2 parents 1c29dc8 + 9eb553e commit 095f892

File tree

9 files changed

+375
-37
lines changed

9 files changed

+375
-37
lines changed

.github/workflows/deploy-auth-service.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Deploy Auth Service
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["CI Test Suite"]
6+
types:
7+
- completed
58
branches: [main]
6-
paths:
7-
- 'server/auth-service/**'
8-
- 'infra/helm-charts/auth-service/**'
9-
- '.github/workflows/deploy-auth-service.yml'
109
pull_request:
1110
types: [opened, synchronize, reopened]
1211
paths:
@@ -23,50 +22,75 @@ on:
2322
jobs:
2423
build-and-deploy:
2524
runs-on: ubuntu-latest
25+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run' }}
2626

2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 2
32+
33+
- name: Check for auth service changes
34+
id: changes
35+
run: |
36+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
37+
# Check if auth service files changed in the commit that triggered CI
38+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
39+
if echo "$CHANGED_FILES" | grep -E "(^server/auth-service/|^infra/helm-charts/auth-service/|^\.github/workflows/deploy-auth-service\.yml)"; then
40+
echo "auth_service_changed=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "auth_service_changed=false" >> $GITHUB_OUTPUT
43+
fi
44+
else
45+
echo "auth_service_changed=true" >> $GITHUB_OUTPUT
46+
fi
3047
3148
- name: Setup Java
49+
if: steps.changes.outputs.auth_service_changed == 'true'
3250
uses: actions/setup-java@v4
3351
with:
3452
java-version: '21'
3553
distribution: 'temurin'
3654

3755
- name: Setup Gradle
56+
if: steps.changes.outputs.auth_service_changed == 'true'
3857
uses: gradle/gradle-build-action@v2
3958
with:
4059
gradle-version: '8.5'
4160

4261
- name: Build Auth Service
62+
if: steps.changes.outputs.auth_service_changed == 'true'
4363
run: |
4464
cd server/auth-service
4565
./gradlew build -x test
4666
echo "✅ Auth service built successfully"
4767
4868
- name: Build Docker Image
69+
if: steps.changes.outputs.auth_service_changed == 'true'
4970
run: |
5071
cd server/auth-service
5172
docker build -t ghcr.io/aet-devops25/team-3/auth-service:${{ github.event.inputs.image_tag || github.sha }} .
5273
docker build -t ghcr.io/aet-devops25/team-3/auth-service:latest .
5374
echo "✅ Docker image built successfully"
5475
5576
- name: Login to GitHub Container Registry
77+
if: steps.changes.outputs.auth_service_changed == 'true'
5678
uses: docker/login-action@v3
5779
with:
5880
registry: ghcr.io
5981
username: ${{ github.actor }}
6082
password: ${{ secrets.GITHUB_TOKEN }}
6183

6284
- name: Push Docker Image
85+
if: steps.changes.outputs.auth_service_changed == 'true'
6386
run: |
6487
cd server/auth-service
6588
docker push ghcr.io/aet-devops25/team-3/auth-service:${{ github.event.inputs.image_tag || github.sha }}
6689
docker push ghcr.io/aet-devops25/team-3/auth-service:latest
6790
echo "✅ Docker image pushed successfully"
6891
6992
- name: Setup Kubernetes tools
93+
if: steps.changes.outputs.auth_service_changed == 'true'
7094
run: |
7195
echo "🔧 Setting up Kubernetes tools..."
7296
@@ -86,6 +110,7 @@ jobs:
86110
helm version
87111
88112
- name: Configure kubectl
113+
if: steps.changes.outputs.auth_service_changed == 'true'
89114
run: |
90115
echo "🔧 Configuring kubectl..."
91116
@@ -117,6 +142,7 @@ jobs:
117142
echo "✅ Kubectl configured"
118143
119144
- name: Deploy Helm Chart
145+
if: steps.changes.outputs.auth_service_changed == 'true'
120146
env:
121147
HELM_RELEASE_NAME: auth-service
122148
CHART_PATH: ./infra/helm-charts/auth-service
@@ -134,6 +160,7 @@ jobs:
134160
echo "✅ Auth service deployed successfully"
135161
136162
- name: Verify Deployment
163+
if: steps.changes.outputs.auth_service_changed == 'true'
137164
run: |
138165
echo "🔍 Verifying auth service deployment..."
139166
@@ -174,6 +201,7 @@ jobs:
174201
kill $PF_PID 2>/dev/null || true
175202
176203
- name: Deployment Summary
204+
if: steps.changes.outputs.auth_service_changed == 'true'
177205
run: |
178206
echo "🌐 Auth Service Deployment Complete!"
179207
echo "📦 Namespace: study-mate"

.github/workflows/deploy-client.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Deploy Client
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["CI Test Suite"]
6+
types:
7+
- completed
58
branches: [main]
6-
paths:
7-
- 'client/**'
8-
- 'infra/helm-charts/client/**'
9-
- '.github/workflows/deploy-client.yml'
109
pull_request:
1110
types: [opened, synchronize, reopened]
1211
paths:
@@ -23,10 +22,28 @@ on:
2322
jobs:
2423
build-and-deploy:
2524
runs-on: ubuntu-latest
25+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run' }}
2626

2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 2
32+
33+
- name: Check for client changes
34+
id: changes
35+
run: |
36+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
37+
# Check if client files changed in the commit that triggered CI
38+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
39+
if echo "$CHANGED_FILES" | grep -E "(^client/|^infra/helm-charts/client/|^\.github/workflows/deploy-client\.yml)"; then
40+
echo "client_changed=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "client_changed=false" >> $GITHUB_OUTPUT
43+
fi
44+
else
45+
echo "client_changed=true" >> $GITHUB_OUTPUT
46+
fi
3047
3148
- name: Setup Node.js
3249
uses: actions/setup-node@v4

.github/workflows/deploy-document-service.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
name: Deploy Document Service
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: ["CI Test Suite"]
6+
types:
7+
- completed
58
branches: [main]
6-
paths:
7-
- 'server/document-service/**'
8-
- 'infra/helm-charts/document-service/**'
9-
- '.github/workflows/deploy-document-service.yml'
109
pull_request:
1110
types: [opened, synchronize, reopened]
1211
paths:
@@ -23,50 +22,75 @@ on:
2322
jobs:
2423
build-and-deploy:
2524
runs-on: ubuntu-latest
25+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run' }}
2626

2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 2
32+
33+
- name: Check for document-service changes
34+
id: changes
35+
run: |
36+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
37+
# Check if document-service files changed in the commit that triggered CI
38+
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
39+
if echo "$CHANGED_FILES" | grep -E "(^server/document-service/|^infra/helm-charts/document-service/|^\.github/workflows/deploy-document-service\.yml)"; then
40+
echo "document_service_changed=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "document_service_changed=false" >> $GITHUB_OUTPUT
43+
fi
44+
else
45+
echo "document_service_changed=true" >> $GITHUB_OUTPUT
46+
fi
3047
3148
- name: Setup Java
49+
if: steps.changes.outputs.document_service_changed == 'true'
3250
uses: actions/setup-java@v4
3351
with:
3452
java-version: '21'
3553
distribution: 'temurin'
3654

3755
- name: Setup Gradle
56+
if: steps.changes.outputs.document_service_changed == 'true'
3857
uses: gradle/gradle-build-action@v2
3958
with:
4059
gradle-version: '8.5'
4160

4261
- name: Build Document Service
62+
if: steps.changes.outputs.document_service_changed == 'true'
4363
run: |
4464
cd server/document-service
4565
./gradlew build -x test
4666
echo "✅ Document service built successfully"
4767
4868
- name: Build Docker Image
69+
if: steps.changes.outputs.document_service_changed == 'true'
4970
run: |
5071
cd server/document-service
5172
docker build -t ghcr.io/aet-devops25/team-3/document-service:${{ github.event.inputs.image_tag || github.sha }} .
5273
docker build -t ghcr.io/aet-devops25/team-3/document-service:latest .
5374
echo "✅ Docker image built successfully"
5475
5576
- name: Login to GitHub Container Registry
77+
if: steps.changes.outputs.document_service_changed == 'true'
5678
uses: docker/login-action@v3
5779
with:
5880
registry: ghcr.io
5981
username: ${{ github.actor }}
6082
password: ${{ secrets.GITHUB_TOKEN }}
6183

6284
- name: Push Docker Image
85+
if: steps.changes.outputs.document_service_changed == 'true'
6386
run: |
6487
cd server/document-service
6588
docker push ghcr.io/aet-devops25/team-3/document-service:${{ github.event.inputs.image_tag || github.sha }}
6689
docker push ghcr.io/aet-devops25/team-3/document-service:latest
6790
echo "✅ Docker image pushed successfully"
6891
6992
- name: Setup Kubernetes tools
93+
if: steps.changes.outputs.document_service_changed == 'true'
7094
run: |
7195
echo "🔧 Setting up Kubernetes tools..."
7296
@@ -86,6 +110,7 @@ jobs:
86110
helm version
87111
88112
- name: Configure kubectl
113+
if: steps.changes.outputs.document_service_changed == 'true'
89114
run: |
90115
echo "🔧 Configuring kubectl..."
91116
@@ -119,6 +144,7 @@ jobs:
119144
120145
121146
- name: Deploy Helm Chart
147+
if: steps.changes.outputs.document_service_changed == 'true'
122148
env:
123149
HELM_RELEASE_NAME: document-service
124150
CHART_PATH: ./infra/helm-charts/document-service
@@ -136,6 +162,7 @@ jobs:
136162
echo "✅ Document service deployed successfully"
137163
138164
- name: Verify Deployment
165+
if: steps.changes.outputs.document_service_changed == 'true'
139166
run: |
140167
echo "🔍 Verifying document service deployment..."
141168
@@ -179,6 +206,7 @@ jobs:
179206
kill $PF_PID 2>/dev/null || true
180207
181208
- name: Deployment Summary
209+
if: steps.changes.outputs.document_service_changed == 'true'
182210
run: |
183211
echo "🌐 Document Service Deployment Complete!"
184212
echo "📦 Namespace: study-mate"

0 commit comments

Comments
 (0)