-
Notifications
You must be signed in to change notification settings - Fork 1
737 lines (645 loc) · 27.8 KB
/
Copy pathgithub-action.yml
File metadata and controls
737 lines (645 loc) · 27.8 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
name: Monext Online Android SDK CI/CD Pipeline
# DÉCLENCHEURS - Quand ce pipeline doit s'exécuter
on:
# Se déclenche lors d'un push sur les branches main ou develop
push:
branches: [ main, develop ]
# Se déclenche aussi lors de la création d'un tag commençant par 'v' (ex: v1.0.0)
tags:
- 'v*'
# Se déclenche lors de l'ouverture ou mise à jour d'une Pull Request
pull_request:
branches: [ develop ]
# VARIABLES GLOBALES - Utilisées dans tous les jobs
env:
ANDROID_COMPILE_SDK: "34"
ANDROID_BUILD_TOOLS: "34.0.0"
ANDROID_SDK_TOOLS: "11076708" # Version des outils de ligne de commande Android
JDK_DISTRIBUTION: 'temurin' # Distribution OpenJDK
JDK_VERSION: '21'
jobs:
# ============================================
# TESTS UNITAIRES ET INSTRUMENTÉS
# ============================================
test:
name: Run Tests
# Machine virtuelle Ubuntu pour exécuter les tests
runs-on: ubuntu-latest
steps:
# Récupère le code source depuis GitHub
- name: Checkout code
uses: actions/checkout@v4
with:
# fetch-depth: 0 récupère tout l'historique Git
# Nécessaire pour que SonarCloud puisse analyser les changements
fetch-depth: 0
# Configure JDK
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}
cache: 'gradle' # Met en cache les dépendances Gradle pour accélérer les builds
# Installe le SDK Android nécessaire pour compiler
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: ${{ env.ANDROID_SDK_TOOLS }}
# Rend le wrapper Gradle exécutable (nécessaire sur Linux)
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Setup Google Services
uses: ./.github/actions/setup-google-services
with:
firebase_app_id: ${{ secrets.FIREBASE_APP_ID }}
firebase_api_key: ${{ secrets.FIREBASE_APP_ID }}
# TESTS UNITAIRES (tests sur la JVM, sans Android)
- name: Run unit tests with coverage
run: ./gradlew testDebugUnitTest --stacktrace
# Sauvegarde les rapports de tests même si les tests échouent
- name: Upload unit test results
uses: actions/upload-artifact@v4
if: always() # S'exécute même en cas d'échec
with:
name: unit-test-results
path: |
**/build/reports/tests/
**/build/reports/jacoco/
**/build/outputs/unit_test_code_coverage/
# TESTS Android
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Tests d'instrumentation sur émulateur
- name: Start emulator and run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
# Configuration de l'émulateur
api-level: 30
arch: x86_64
profile: Nexus 6
avd-name: test
# Options pour optimiser l'émulateur en CI (pas d'interface graphique)
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
disable-animations: true # Désactive les animations pour accélérer les tests
# Commande à exécuter une fois l'émulateur démarré
script: ./gradlew createDebugCoverageReport --stacktrace
# Sauvegarde les résultats des tests instrumentés
- name: Upload instrumented test results
uses: actions/upload-artifact@v4
if: always()
with:
name: instrumented-test-results
path: |
**/build/reports/androidTests/
**/build/reports/coverage/
**/build/outputs/code_coverage/
# Genere un rapport qui combine les TU et les AndroidTest
- name: Generate unified coverage report
run: |
./gradlew jacocoTestReport --stacktrace
echo "Coverage report generated at: monext/build/reports/jacoco/jacocoTestReport/"
- name: Upload JaCoCo report
uses: actions/upload-artifact@v4
if: always()
with:
name: jacoco-report
path: '**/build/reports/jacoco/'
# ============================================
# ANALYSE SONARCLOUD
# ============================================
sonarcloud:
name: SonarCloud Analysis
runs-on: ubuntu-latest
# Ne s'exécute qu'après le succès des tests
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Historique complet pour l'analyse
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}
cache: 'gradle'
- name: Setup Google Services
uses: ./.github/actions/setup-google-services
with:
firebase_app_id: ${{ secrets.FIREBASE_APP_ID }}
firebase_api_key: ${{ secrets.FIREBASE_APP_ID }}
# Cache pour les packages SonarCloud (accélère l'analyse)
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Télécharge les artifacts des tests (incluant JaCoCo)
- name: Download test artifacts
uses: actions/download-artifact@v4
with:
path: build-artifacts
- name: Restore coverage files
run: |
cp -r build-artifacts/jacoco-report/* ./ 2>/dev/null || true
cp -r build-artifacts/unit-test-results/* ./ 2>/dev/null || true
cp -r build-artifacts/instrumented-test-results/* ./ 2>/dev/null || true
- name: Check coverage report
run: |
echo "Checking for coverage files..."
find . -name "*.exec" -type f
find . -name "*.ec" -type f
find . -name "jacocoTestReport.xml" -type f
# Build minimal puis Sonar
- name: Run SonarCloud analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
./gradlew assembleDebug --stacktrace
./gradlew sonar --info -x test -x testDebugUnitTest
# ============================================
# ============================================
# BUILD ET PUBLICATION DU SDK => Release uniquement
# => Déploiement sonatype + github release
# ============================================
# ============================================
build-and-publish-release:
name: Build and Publish SDK
runs-on: ubuntu-latest
needs: [test, sonarcloud]
if: |
github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/release/')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: ${{ env.ANDROID_SDK_TOOLS }}
- name: Setup Google Services
uses: ./.github/actions/setup-google-services
with:
firebase_app_id: ${{ secrets.FIREBASE_APP_ID }}
firebase_api_key: ${{ secrets.FIREBASE_APP_ID }}
- name: Get Version
id: version
uses: ./.github/actions/setup-sdk-version
# IMPORT GPG KEY
- name: Import GPG key
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
echo "📝 Import de la clé GPG pour la signature..."
echo "$SIGNING_KEY" | base64 -d | gpg --batch --import
echo ""
echo "🔍 Vérification des clés importées :"
gpg --list-secret-keys --keyid-format=long
echo ""
echo "✅ Clé GPG importée avec succès"
# BUILD & DOCUMENTATION
- name: Build Release AAR
run: ./gradlew :monext:assembleRelease
env:
THREEDS_API_ACCESS_KEY: ${{ secrets.THREEDS_API_ACCESS_KEY }}
- name: Generate documentation
run: ./gradlew :monext:dokkaHtml
- name: Upload AAR artifact
uses: actions/upload-artifact@v4
with:
name: sdk-aar
path: monext/build/outputs/aar/*.aar
# Sign le bundle
- name: Publish and sign artifacts
run: ./gradlew :monext:publishReleasePublicationToStagingRepository --stacktrace
env:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
THREEDS_API_ACCESS_KEY: ${{ secrets.THREEDS_API_ACCESS_KEY }}
# Préparation de la clé GPG pour la signature Maven Central
- name: Prepare GPG keys for JReleaser
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
echo "📝 Extraction des clés GPG..."
# Décode la clé complète
echo "$SIGNING_KEY" | base64 -d > /tmp/complete-key.asc
# Importe dans GPG temporairement
gpg --batch --import /tmp/complete-key.asc
# Récupère le KEY_ID
KEY_ID=$(gpg --list-secret-keys --keyid-format=long | grep sec | awk '{print $2}' | cut -d'/' -f2 | head -1)
echo "Key ID: $KEY_ID"
# Exporte la clé PUBLIQUE
gpg --armor --export $KEY_ID > /tmp/public-key.asc
# Exporte la clé PRIVÉE
gpg --armor --export-secret-keys $KEY_ID > /tmp/secret-key.asc
# Met les chemins dans l'environnement
echo "GPG_PUBLIC_KEY_FILE=/tmp/public-key.asc" >> $GITHUB_ENV
echo "GPG_SECRET_KEY_FILE=/tmp/secret-key.asc" >> $GITHUB_ENV
echo "✅ Clés GPG préparées"
# PUBLICATION MAVEN CENTRAL via JReleaser
- name: Deploy to Maven Central (Staging)
run: ./gradlew :monext:jreleaserDeploy --no-configuration-cache --stacktrace
env:
JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.MAVEN_USERNAME }}
JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
JRELEASER_GPG_PUBLIC_KEY: ${{ env.GPG_PUBLIC_KEY_FILE }}
JRELEASER_GPG_SECRET_KEY: ${{ env.GPG_SECRET_KEY_FILE }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publication sur GitHub Packages
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
monext/build/outputs/aar/*.aar
CHANGELOG.md
generate_release_notes: true
draft: false
prerelease: false
tag_name: ${{ steps.version.outputs.VERSION_NAME }}
name: Monext Online Android SDK Release v${{ steps.version.outputs.VERSION_NAME }}
# Permet de mettre à jour une release existante si elle existe déjà.
fail_on_unmatched_files: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ============================================
# ============================================
# BUILD ET DISTRIBUTION QA (branche develop)
# ============================================
# ============================================
build-apk-qa-release:
name: Build App Demo QA Release
runs-on: ubuntu-latest
needs: [test, sonarcloud]
# Uniquement sur develop ET si les tests passent
if: github.ref == 'refs/heads/develop' && needs.test.result == 'success' && needs.sonarcloud.result == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: ${{ env.JDK_DISTRIBUTION }}
java-version: ${{ env.JDK_VERSION }}
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: ${{ env.ANDROID_SDK_TOOLS }}
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Decode and save keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > ${{ github.workspace }}/keystore.jks
echo "✓ Keystore decoded"
# RÉCUPÉRATION DE LA VERSION
- name: Get Version
id: version
uses: ./.github/actions/setup-sdk-version
- name: Setup Google Services
uses: ./.github/actions/setup-google-services
with:
firebase_app_id: ${{ secrets.FIREBASE_APP_ID }}
firebase_api_key: ${{ secrets.FIREBASE_CURRENT_KEY }}
# BUILD DE L'APP DÉMO (compile automatiquement le SDK et signe l'APK)
- name: Build Demo App and SDK
run: |
echo "📱 Building app (will automatically build SDK in Release mode)..."
./gradlew :app:assembleRelease --info
echo "✓ Build completed successfully!"
env:
THREEDS_API_ACCESS_KEY: ${{ secrets.THREEDS_API_ACCESS_KEY }}
KEYSTORE_PATH: ${{ github.workspace }}/keystore.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
- name: Get commit information
id: commit_info
run: |
echo "🔍 Récupération des informations de commit..."
# Déterminer la source du message
if [ "${{ github.event_name }}" == "push" ]; then
# Événement push : utiliser github.event
COMMIT_MSG="${{ github.event.head_commit.message }}"
COMMIT_AUTHOR="${{ github.event.head_commit.author.name }}"
echo "Source: GitHub event (push)"
elif [ "${{ github.event_name }}" == "pull_request" ]; then
# Pull request : utiliser le titre de la PR
COMMIT_MSG="PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
COMMIT_AUTHOR="${{ github.actor }}"
echo "Source: Pull Request"
else
# Autres cas : utiliser git log
COMMIT_MSG=$(git log -1 --pretty=format:"%s")
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
echo "Source: Git log (workflow_dispatch ou autre)"
fi
# Si toujours vide, message par défaut
if [ -z "$COMMIT_MSG" ]; then
COMMIT_MSG="Build automatique"
COMMIT_AUTHOR="${{ github.actor }}"
fi
# Récupérer les 5 derniers commits pour le changelog
RECENT_COMMITS=$(git log -5 --pretty=format:"• %s" --no-merges)
# Sauvegarder dans les outputs
echo "message<<EOF" >> $GITHUB_OUTPUT
echo "$COMMIT_MSG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "author=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
echo "recent_commits<<EOF" >> $GITHUB_OUTPUT
echo "$RECENT_COMMITS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "✓ Commit message: ${COMMIT_MSG}"
echo "✓ Author: ${COMMIT_AUTHOR}"
# ============================================
# PRÉPARATION de l'APK + release note
# ============================================
- name: Prepare artifacts
run: |
mkdir -p qa-release
# Copier l'APK de l'app demo
cp app/build/outputs/apk/release/*.apk qa-release/
# Récupération du fileName
APK_FILE=$(find qa-release -name "*.apk" | head -1)
APK_FILENAME=$(basename "$APK_FILE")
# Créer le fichier de release notes
cat > qa-release/RELEASE_NOTES.txt <<EOF
══════════════════════════════════════════════════════
📱 MONEXT DEMO APP (Android SDK) - Version QA
══════════════════════════════════════════════════════
📱 Fichier APK
Nom original: ${APK_FILENAME}
Taille: $(du -h "$APK_FILE" | cut -f1)
Version SDK : ${{ steps.version.outputs.VERSION_NAME }}
Build Number : ${{ steps.version.outputs.VERSION_CODE }}
Branch : ${{ github.ref_name }}
Date : $(date +'%Y-%m-%d %H:%M:%S')
Auteur : ${{ github.actor }}
══════════════════════════════════════════════════════
📝 Dernier changement:
${{ steps.commit_info.outputs.message }}
📋 Changements récents:
${{ steps.commit_info.outputs.recent_commits }}
══════════════════════════════════════════════════════
EOF
echo "✓ Artefacts préparés"
ls -lh qa-release/
# ============================================
# FIREBASE APP DISTRIBUTION
# ============================================
- name: Setup Node.js (for Firebase CLI)
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Setup Firebase Authentication
run: |
# Recupération du Service Account pour la connexion
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASE64 }}" | base64 -d > firebase-sa.json
# Définir la variable d'environnement
echo "GOOGLE_APPLICATION_CREDENTIALS=${{ github.workspace }}/firebase-sa.json" >> $GITHUB_ENV
echo "✓ Firebase authentication configured"
- name: Upload to Firebase App Distribution
run: |
APK_FILE=$(find qa-release -name "*.apk" | head -1)
APK_FILENAME=$(basename "$APK_FILE")
echo "📤 Uploading ${APK_FILENAME} to Firebase..."
firebase appdistribution:distribute "$APK_FILE" \
--app "${{ secrets.FIREBASE_APP_ID }}" \
--groups "qa-team, squad3, monext-android" \
--release-notes-file "qa-release/RELEASE_NOTES.txt"
echo "✅ APK uploaded successfully to Firebase App Distribution"
- name: Cleanup files
if: always()
run: |
rm -f ${{ github.workspace }}/keystore.jks
rm -f ${{ github.workspace }}/firebase-sa.json
rm -f app/google-services.json
echo "✓ Cleanup completed"
# ============================================
# ============================================
# NOTIFICATIONS Teams
# ============================================
# ============================================
notify:
name: Teams Notification
runs-on: ubuntu-latest
if: always()
needs: [test, sonarcloud, build-apk-qa-release, build-and-publish-release]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Version
id: version
uses: ./.github/actions/setup-sdk-version
# ============================================
# CHECK 1 : Check Notification QA
# ============================================
- name: Should send QA Notification
id: teams_notif_qualif
if: |
github.ref == 'refs/heads/develop' &&
needs.test.result == 'success' &&
needs.sonarcloud.result == 'success' &&
needs.build-apk-qa-release.result == 'success'
run: |
TEAMS_WEBHOOK_URL="${{ secrets.TEAMS_WEBHOOK_URL_QUALIF }}"
SHOULD_SEND="yes"
NOTIFICATION_TYPE="QA"
echo "webhook_url=${TEAMS_WEBHOOK_URL}" >> $GITHUB_OUTPUT
echo "should_send=${SHOULD_SEND}" >> $GITHUB_OUTPUT
echo "notif_type=${NOTIFICATION_TYPE}" >> $GITHUB_OUTPUT
echo "Should send QA notification => ${SHOULD_SEND}"
# ============================================
# CHECK 2 : Check Notification Release
# ============================================
- name: Should send Release Notification
id: teams_notif_release
if: |
(github.ref == 'refs/heads/main' ||
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/v'))
run: |
TEAMS_WEBHOOK_URL="${{ secrets.TEAMS_WEBHOOK_URL_SDK_MOBILE }}"
SHOULD_SEND="yes"
NOTIFICATION_TYPE="Release"
BUILD_RESULT="${{ needs.build-and-publish-release.result }}"
# Check du statut
if [[ "$BUILD_RESULT" == "success" ]]; then
ICON_COLOR="Good"
ICON="CheckmarkStarburst"
STATUS_TEXT="✅ success"
elif [[ "$BUILD_RESULT" == "failure" ]]; then
ICON_COLOR="Attention"
ICON="DismissCircle"
STATUS_TEXT="❌ Échec"
else
ICON_COLOR="Warning"
ICON="Warning"
STATUS_TEXT="⚠️ Unknow"
fi
# On passe les variables via outputs
echo "webhook_url=${TEAMS_WEBHOOK_URL}" >> $GITHUB_OUTPUT
echo "should_send=${SHOULD_SEND}" >> $GITHUB_OUTPUT
echo "notif_type=${NOTIFICATION_TYPE}" >> $GITHUB_OUTPUT
echo "icon_color=${ICON_COLOR}" >> $GITHUB_OUTPUT
echo "icon=${ICON}" >> $GITHUB_OUTPUT
echo "status_text=${STATUS_TEXT}" >> $GITHUB_OUTPUT
echo "Should send Release notification => ${SHOULD_SEND} (status: ${STATUS_TEXT})"
# ============================================
# ENVOI DE LA NOTIFICATION (un seul step)
# ============================================
- name: Send Teams Notification
# ✅ S'exécute si AU MOINS UN des deux checks dit "yes"
if: |
steps.teams_notif_qualif.outputs.should_send == 'yes' ||
steps.teams_notif_release.outputs.should_send == 'yes'
run: |
# ✅ Récupérer les variables depuis les outputs
if [[ "${{ steps.teams_notif_qualif.outputs.should_send }}" == "yes" ]]; then
WEBHOOK_URL="${{ steps.teams_notif_qualif.outputs.webhook_url }}"
NOTIF_TYPE="${{ steps.teams_notif_qualif.outputs.notif_type }}"
ICON_COLOR="Good"
ICON="CheckmarkStarburst"
STATUS_TEXT="✅ QA Release disponible"
EXTRA_MESSAGE="📱 L'APK est maintenant disponible sur Firebase App Distribution. Les testeurs ont reçu une notification automatique."
FIREBASE_ACTION='
{
"type": "Action.OpenUrl",
"title": "📱 Ouvrir Firebase Console",
"url": "https://console.firebase.google.com/project/monext-android-sdk/appdistribution/app/android:com.monext.sdkexample/releases"
},'
RELEASE_ACTION=""
else
WEBHOOK_URL="${{ steps.teams_notif_release.outputs.webhook_url }}"
NOTIF_TYPE="${{ steps.teams_notif_release.outputs.notif_type }}"
ICON_COLOR="${{ steps.teams_notif_release.outputs.icon_color }}"
ICON="${{ steps.teams_notif_release.outputs.icon }}"
STATUS_TEXT="${{ steps.teams_notif_release.outputs.status_text }}"
EXTRA_MESSAGE="Publication sur Maven Central et GitHub Packages."
FIREBASE_ACTION=""
RELEASE_ACTION='
{
"type": "Action.OpenUrl",
"title": "🚀 Voir la release",
"url": "https://github.com/${{ github.repository }}/releases"
},{
"type": "Action.OpenUrl",
"title": "📱 Voir sur Maven Central",
"url": "https://central.sonatype.com/artifact/com.monext/monext-android-sdk"
},'
fi
echo "Sending ${NOTIF_TYPE} notification to Teams..."
curl -X POST "${WEBHOOK_URL}" \
-H "Content-Type: application/json" \
-d @- << EOF
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": {
"type": "AdaptiveCard",
"\$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.4",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "auto",
"height": "stretch",
"items": [
{
"type": "Icon",
"name": "${ICON}",
"style": "Filled",
"color": "${ICON_COLOR}"
}
],
"spacing": "None"
},
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "TextBlock",
"text": "Publication **SDK Android** - ${STATUS_TEXT}",
"wrap": true,
"size": "Large",
"weight": "Bolder"
}
],
"spacing": "Small"
}
],
"spacing": "None"
},
{
"type": "TextBlock",
"text": "_version ${{ steps.version.outputs.VERSION_NAME }} (build ${{ steps.version.outputs.VERSION_CODE }})_",
"wrap": true,
"isSubtle": true,
"spacing": "Small"
},
{
"type": "FactSet",
"facts": [
{
"title": "Repository:",
"value": "${{ github.repository }}"
},
{
"title": "Branch/Tag:",
"value": "${{ github.ref_name }}"
},
{
"title": "Auteur:",
"value": "${{ github.actor }}"
}
],
"separator": true
},
{
"type": "TextBlock",
"text": "${EXTRA_MESSAGE}",
"wrap": true,
"separator": true
}
],
"actions": [
${FIREBASE_ACTION}
${RELEASE_ACTION}
{
"type": "Action.OpenUrl",
"title": "📊 Voir le build",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
}
]
}
EOF
echo "✅ ${NOTIF_TYPE} notification sent successfully"