Skip to content

Commit e05b5e5

Browse files
authored
Merge pull request #37 from AET-DevOps25/feature/combine-ci-cd
Combine each service specific ci-cd pipeline into one big ci-cd including helm deployment
2 parents 69e5921 + 02199d3 commit e05b5e5

File tree

5 files changed

+244
-234
lines changed

5 files changed

+244
-234
lines changed

.github/workflows/ci-cd.yml

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/**
8+
paths:
9+
- 'genai/**'
10+
- 'server/**'
11+
- 'client/**'
12+
- '.github/workflows/ci-cd.yml'
13+
14+
#----- Detect changes in services and trigger builds accordingly ------#
15+
jobs:
16+
detect-changes:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
genai: ${{ steps.filter.outputs.genai }}
20+
server: ${{ steps.filter.outputs.server }}
21+
client: ${{ steps.filter.outputs.client }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- id: filter
25+
uses: dorny/paths-filter@v3
26+
with:
27+
filters: |
28+
genai:
29+
- 'genai/**'
30+
server:
31+
- 'server/**'
32+
client:
33+
- 'client/**'
34+
35+
#-------- Build and Test Services -----------------------------#
36+
build-genai:
37+
needs: detect-changes
38+
if: |
39+
startsWith(github.ref, 'refs/heads/feature/') && needs.detect-changes.outputs.genai == 'true'
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.11'
49+
50+
- name: Install dependencies
51+
run: pip install -r requirements.txt
52+
working-directory: genai
53+
54+
- name: Lint Python code
55+
run: |
56+
pip install flake8
57+
flake8 . || exit 1
58+
working-directory: genai
59+
60+
build-server:
61+
needs: detect-changes
62+
if: |
63+
startsWith(github.ref, 'refs/heads/feature/') && needs.detect-changes.outputs.server == 'true'
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout code
67+
uses: actions/checkout@v4
68+
69+
- name: Set up JDK 21
70+
uses: actions/setup-java@v4
71+
with:
72+
distribution: 'temurin'
73+
java-version: 21
74+
75+
- name: Cache Gradle packages
76+
uses: actions/cache@v4
77+
with:
78+
path: |
79+
~/.gradle/caches
80+
~/.gradle/wrapper
81+
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
82+
restore-keys: |
83+
gradle-${{ runner.os }}-
84+
85+
- name: Grant execute permission for gradlew
86+
run: chmod +x gradlew
87+
working-directory: server
88+
89+
- name: Build with Gradle
90+
run: ./gradlew build
91+
working-directory: server
92+
93+
- name: Run tests
94+
run: ./gradlew test
95+
working-directory: server
96+
97+
build-client:
98+
needs: detect-changes
99+
if: |
100+
startsWith(github.ref, 'refs/heads/feature/') && needs.detect-changes.outputs.client == 'true'
101+
runs-on: ubuntu-latest
102+
env:
103+
NODE_ENV: production
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v4
107+
108+
- name: Set up Node.js
109+
uses: actions/setup-node@v4
110+
with:
111+
node-version: "22"
112+
cache: "npm"
113+
cache-dependency-path: client/package-lock.json
114+
115+
- name: Install dependencies
116+
run: npm install --include=dev
117+
working-directory: client
118+
119+
- name: Build with Node
120+
run: npm run build
121+
working-directory: client
122+
123+
#-------- Publish Docker images of services -----------------------------#
124+
docker-release-genai:
125+
needs: detect-changes
126+
if: github.ref == 'refs/heads/main' && needs.detect-changes.outputs.genai == 'true'
127+
runs-on: ubuntu-latest
128+
permissions:
129+
contents: read
130+
packages: write
131+
steps:
132+
- name: Checkout code
133+
uses: actions/checkout@v4
134+
135+
- name: Log in to GitHub Container Registry
136+
uses: docker/login-action@v3
137+
with:
138+
registry: ghcr.io
139+
username: ${{ github.actor }}
140+
password: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Build Docker image
143+
working-directory: genai
144+
run: docker build -t ghcr.io/aet-devops25/team-continuous-disappointment/genai:latest .
145+
146+
- name: Push Docker image
147+
run: docker push ghcr.io/aet-devops25/team-continuous-disappointment/genai:latest
148+
149+
docker-release-server:
150+
needs: detect-changes
151+
if: github.ref == 'refs/heads/main' && needs.detect-changes.outputs.server == 'true'
152+
runs-on: ubuntu-latest
153+
permissions:
154+
contents: read
155+
packages: write
156+
steps:
157+
- name: Checkout code
158+
uses: actions/checkout@v4
159+
160+
- name: Set up JDK 21
161+
uses: actions/setup-java@v4
162+
with:
163+
distribution: 'temurin'
164+
java-version: 21
165+
166+
- name: Grant execute permission for gradlew
167+
run: chmod +x gradlew
168+
working-directory: server
169+
170+
- name: Build with Gradle
171+
run: ./gradlew build
172+
working-directory: server
173+
174+
- name: Run tests
175+
run: ./gradlew test
176+
working-directory: server
177+
178+
- name: Log in to GitHub Container Registry
179+
uses: docker/login-action@v3
180+
with:
181+
registry: ghcr.io
182+
username: ${{ github.actor }}
183+
password: ${{ secrets.GITHUB_TOKEN }}
184+
185+
- name: Build Docker image
186+
working-directory: server
187+
run: docker build -t ghcr.io/aet-devops25/team-continuous-disappointment/server:latest .
188+
189+
- name: Push Docker image
190+
run: docker push ghcr.io/aet-devops25/team-continuous-disappointment/server:latest
191+
192+
docker-release-client:
193+
needs: detect-changes
194+
if: github.ref == 'refs/heads/main' && needs.detect-changes.outputs.client == 'true'
195+
runs-on: ubuntu-latest
196+
permissions:
197+
contents: read
198+
packages: write
199+
env:
200+
NODE_ENV: production
201+
steps:
202+
- name: Checkout code
203+
uses: actions/checkout@v4
204+
205+
- name: Log in to GitHub Container Registry
206+
uses: docker/login-action@v3
207+
with:
208+
registry: ghcr.io
209+
username: ${{ github.actor }}
210+
password: ${{ secrets.GITHUB_TOKEN }}
211+
212+
- name: Build Docker image
213+
working-directory: client
214+
run: docker build -t ghcr.io/aet-devops25/team-continuous-disappointment/client:latest .
215+
216+
- name: Push Docker image
217+
run: docker push ghcr.io/aet-devops25/team-continuous-disappointment/client:latest
218+
219+
#-------- Deploy Services on k8s cluster via helm -----------------------------#
220+
221+
helm-deploy:
222+
needs: [detect-changes, docker-release-genai, docker-release-server, docker-release-client]
223+
if: |
224+
github.ref == 'refs/heads/main' && (
225+
needs.detect-changes.outputs.genai == 'true' ||
226+
needs.detect-changes.outputs.server == 'true' ||
227+
needs.detect-changes.outputs.client == 'true'
228+
)
229+
runs-on: ubuntu-latest
230+
steps:
231+
- name: Checkout code
232+
uses: actions/checkout@v4
233+
234+
- name: Set up Helm
235+
uses: azure/setup-helm@v3
236+
237+
- name: Set up Kubeconfig
238+
run: |
239+
mkdir -p ~/.kube
240+
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
241+
chmod 600 ~/.kube/config
242+
243+
- name: Deploy with Helm
244+
run: helm -n team-continuous-disappointment upgrade recip-ai ./recipai-chart --set secrets.gitlabClientSecret="${{ secrets.PROD_CLIENT_SECRET }}"

.github/workflows/client-ci-cd.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/genai-ci-cd.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/helm-deploy.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)