@@ -3,13 +3,41 @@ name: CI / CD – TaskFlow
33on :
44 push :
55 branches : [ main, develop ]
6+ paths :
7+ - ' Backend/**'
8+ - ' Frontend/**'
9+ - ' .github/workflows/**'
610 pull_request :
711 branches : [ main, develop ]
12+ paths :
13+ - ' Backend/**'
14+ - ' Frontend/**'
15+ - ' .github/workflows/**'
816
917jobs :
18+ changes :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ backend : ${{ steps.filter.outputs.backend }}
22+ frontend : ${{ steps.filter.outputs.frontend }}
23+ steps :
24+ - uses : actions/checkout@v4
25+ - uses : dorny/paths-filter@v3
26+ id : filter
27+ with :
28+ filters : |
29+ backend:
30+ - 'Backend/**'
31+ - 'Backend/Dockerfile'
32+ frontend:
33+ - 'Frontend/**'
34+ - 'Frontend/Dockerfile'
35+
1036 # 1. Checkout + Setup .NET
11- setup :
37+ setup-backend :
1238 runs-on : ubuntu-latest
39+ needs : changes
40+ if : ${{ needs.changes.outputs.backend == 'true' }}
1341 outputs :
1442 cache-key : ${{ steps.cache.outputs.cache-key }}
1543 steps :
3260 restore-keys : ${{ runner.os }}-nuget-
3361
3462 # 2. Restore dependencies + Build
35- build :
36- needs : setup
63+ build-backend :
64+ needs : setup-backend
3765 runs-on : ubuntu-latest
3866 steps :
3967 - name : Checkout code
5179 run : dotnet build ./Backend/FlowTasks.sln --configuration Release --no-restore
5280
5381 # 3. Unit Tests + Coverage
54- test :
55- needs : build
82+ test-backend :
83+ needs : build-backend
5684 runs-on : ubuntu-latest
5785 services :
5886 postgres :
97125 path : " **/TestResults/*.trx"
98126
99127 # 4. Code Quality
100- quality :
101- needs : test
128+ quality-backend :
129+ needs : test-backend
102130 runs-on : ubuntu-latest
103131 steps :
104132 - name : Checkout code
@@ -122,9 +150,8 @@ jobs:
122150 -Dsonar.qualitygate.wait=true
123151
124152 # 5. Build & Push Docker Image
125- docker :
126- needs : quality
127- if : github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
153+ docker-backend :
154+ needs : build-backend
128155 runs-on : ubuntu-latest
129156 permissions :
130157 packages : write
@@ -148,8 +175,93 @@ jobs:
148175 uses : docker/build-push-action@v6
149176 with :
150177 context : .
178+ file : ./Backend/Dockerfile
179+ push : true
180+ tags : |
181+ ghcr.io/${{ github.repository_owner }}/taskflow:latest
182+ ghcr.io/${{ github.repository_owner }}/taskflow:${{ github.sha }}
183+ ghcr.io/${{ github.repository_owner }}/taskflow:${{ github.ref_name == 'main' && 'stable' || 'dev' }}
184+
185+ # ======================== FRONTEND JOBS ========================
186+
187+ setup-frontend :
188+ needs : changes
189+ if : ${{ needs.changes.outputs.frontend == 'true' }}
190+ runs-on : ubuntu-latest
191+ steps :
192+ - name : Checkout code
193+ uses : actions/checkout@v4
194+
195+ - name : Setup Node.js
196+ uses : actions/setup-node@v4
197+ with :
198+ node-version : 20
199+ cache : ' npm'
200+ cache-dependency-path : Frontend/package-lock.json
201+
202+ - name : Install dependencies
203+ run : cd Frontend && npm ci --legacy-peer-deps
204+
205+ - name : Lint Frontend
206+ run : cd Frontend && npm install && npx ng lint
207+
208+ # Décommente si tu ajoutes des tests Angular
209+ # - name: Run tests
210+ # run: cd Frontend && npm run test -- --watch=false --browsers=ChromeHeadless
211+
212+ build-frontend :
213+ needs : setup-frontend
214+ runs-on : ubuntu-latest
215+ steps :
216+ - name : Checkout code
217+ uses : actions/checkout@v4
218+
219+ - name : Setup Node.js
220+ uses : actions/setup-node@v4
221+ with :
222+ node-version : 20
223+ cache : ' npm'
224+ cache-dependency-path : Frontend/package-lock.json
225+
226+ - name : Install & Build
227+ run : |
228+ cd Frontend
229+ npm ci --legacy-peer-deps
230+ npm run build -- --configuration production
231+
232+ - name : Upload build artifact
233+ uses : actions/upload-artifact@v4
234+ with :
235+ name : frontend-dist
236+ path : Frontend/dist/
237+
238+ docker-frontend :
239+ needs : build-frontend
240+ runs-on : ubuntu-latest
241+ permissions :
242+ packages : write
243+ contents : read
244+ steps :
245+ - name : Checkout code
246+ uses : actions/checkout@v4
247+
248+ - name : Set up Docker Buildx
249+ uses : docker/setup-buildx-action@v3
250+
251+ - name : Login to GitHub Container Registry
252+ uses : docker/login-action@v3
253+ with :
254+ registry : ghcr.io
255+ username : ${{ github.actor }}
256+ password : ${{ secrets.GITHUB_TOKEN }}
257+
258+ - name : Build and push frontend image
259+ uses : docker/build-push-action@v6
260+ with :
261+ context : ./Frontend
262+ file : ./Frontend/Dockerfile
151263 push : true
152264 tags : |
153- ghcr.io/$$ {{ github.repository_owner }}/ $${{ github.event.repository.name }} :latest
154- ghcr.io/$$ {{ github.repository_owner }}/ $${{ github.event.repository.name }} :${{ github.sha }}
155- ghcr.io/$$ {{ github.repository_owner }}/ $${{ github.event.repository.name }} :${{ github.ref_name == 'main' && 'stable' || 'dev' }}
265+ ghcr.io/${{ github.repository_owner }}/taskflow-frontend :latest
266+ ghcr.io/${{ github.repository_owner }}/taskflow-frontend :${{ github.sha }}
267+ ghcr.io/${{ github.repository_owner }}/taskflow-frontend :${{ github.ref_name == 'main' && 'stable' || 'dev' }}
0 commit comments