-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiTenant_deploy_and_Integration_test_LatestVersion.yml
More file actions
1758 lines (1631 loc) Β· 79.3 KB
/
Copy pathmultiTenant_deploy_and_Integration_test_LatestVersion.yml
File metadata and controls
1758 lines (1631 loc) Β· 79.3 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
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Multi Tenancy Deploy & Integration Test LatestVersionπ
# This workflow now runs ONLY after the main "Multi Tenancy Deploy & Integration Test" workflow
# (multiTenant_deploy_and_Integration_test.yml) has completed successfully. It can still be
# triggered manually via workflow_dispatch if needed.
on:
workflow_run:
workflows: ["Multi Tenancy Deploy & Integration Testπ"]
types: [completed]
workflow_dispatch:
permissions:
contents: read
pull-requests: read
packages: read # Added permission to read packages
jobs:
deploy:
environment: dev
#Run only if the triggering workflow concluded successfully
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout this repository π
uses: actions/checkout@v6
- name: Set up JDK 21 β
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '21'
- name: Build and package π¦
run: |
echo "π¨ Building and packaging..."
mvn clean install -P unit-tests -DskipIntegrationTests
echo "β
Build completed successfully!"
- name: Setup Node.js π’
uses: actions/setup-node@v3
with:
node-version: '20' # Ensure to use at least version 18
- name: Install MBT βοΈ
run: |
echo "π§ Installing MBT..."
npm install -g mbt
echo "β
MBT installation complete!"
- name: Override cds.services.version (runtime only)
env:
TARGET_CDS_SERVICES_VERSION: 4.3.1
run: |
set -e
echo "=== cds.services.version Override Step ==="
echo "Target version to apply: ${TARGET_CDS_SERVICES_VERSION}"
FILES=$(grep -Rl "<cds.services.version>" app/multi-tenant/central-space/cloud-cap-samples-java | grep pom.xml || true)
if [ -z "$FILES" ]; then
echo "No pom.xml files with <cds.services.version> found" >&2; exit 1;
fi
echo "POM files containing property:"; echo "$FILES" | sed 's/^/ - /'
echo "\nCurrent raw occurrences BEFORE override:"
for f in $FILES; do
# Show each occurrence with line number (first 3 if multiple)
MATCHES=$(grep -n "<cds.services.version>" "$f" | head -3 || true)
if [ -n "$MATCHES" ]; then
echo "--- $f"; echo "$MATCHES"
fi
done
echo "\nResolving effective value BEFORE override via mvn help:evaluate ..."
RESOLVED_BEFORE=$(mvn -q -DforceStdout help:evaluate -f app/multi-tenant/central-space/cloud-cap-samples-java/pom.xml -Dexpression=cds.services.version || true)
echo "Effective cds.services.version before override: '${RESOLVED_BEFORE}'"
if [ "${RESOLVED_BEFORE}" = "${TARGET_CDS_SERVICES_VERSION}" ]; then
echo "NOTE: Effective value already equals target; files will still be normalized to target string."
fi
echo "\nApplying override ..."
# Perform in-place replacement for each file
for f in $FILES; do
sed -i "s|<cds.services.version>[^<]*</cds.services.version>|<cds.services.version>${TARGET_CDS_SERVICES_VERSION}</cds.services.version>|" "$f"
done
echo "\nRaw occurrences AFTER override:"
grep -R "<cds.services.version>" $FILES || true
echo "\nResolving effective value AFTER override via mvn help:evaluate ..."
RESOLVED_AFTER=$(mvn -q -DforceStdout help:evaluate -f app/multi-tenant/central-space/cloud-cap-samples-java/pom.xml -Dexpression=cds.services.version || true)
echo "Effective cds.services.version after override: '${RESOLVED_AFTER}'"
if [ "${RESOLVED_AFTER}" != "${TARGET_CDS_SERVICES_VERSION}" ]; then
echo "WARNING: Resolved value does not match target (profiles or parent POM could be overriding it)." >&2
fi
echo "(Not committing these changes)"
echo "=== Override Step Complete ==="
shell: bash
- name: Change directory to cloud-cap-samples-java π
working-directory: app/multi-tenant/central-space/cloud-cap-samples-java
run: |
pwd
echo "βοΈ Directory changed!"
- name: Set REPOSITORY_ID π
id: set_repository_id
run: |
echo "repository_id=${{ secrets.MULTITENANT_REPOSITORY_ID }}" >> $GITHUB_OUTPUT
- name: Run mbt build π¨
working-directory: app/multi-tenant/central-space/cloud-cap-samples-java
run: |
echo "π Running MBT build..."
echo "java version:"
java --version
sed -i 's|__REPOSITORY_ID__|${{ steps.set_repository_id.outputs.repository_id }}|g' mta.yaml
mbt build
echo "β
MBT build completed!"
- name: Deploy to Cloud Foundry βοΈ
working-directory: app/multi-tenant/central-space/cloud-cap-samples-java
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Deploying..."
echo "π§ Installing Cloud Foundry CLI and plugins..."
# Install cf CLI plugin
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt update
sudo apt install cf8-cli
cf install-plugin multiapps -f
echo "β
Cloud Foundry CLI setup complete!"
# Login to Cloud Foundry again to ensure session is active
echo "π Logging in to Cloud Foundry..."
cf login -a "$CF_API" -u "$CF_USER" -p "$CF_PASSWORD" -o "$CF_ORG" -s "$CF_SPACE" > /dev/null
echo "β
Logged in successfully!"
# Deploy the application
echo "π Current directory.."
pwd
ls -lrth
echo "βΆοΈ Running cf deploy..."
cf deploy mta_archives/bookshop-mt_1.0.0.mtar -f
echo "β
Deployment complete!"
# Parallel integration tests using matrix strategy
integration-test:
environment: dev
needs: deploy
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tokenFlow: [namedUser, technicalUser]
tenant: [TENANT1, TENANT2]
testClass:
- IntegrationTest_SingleFacet
- IntegrationTest_MultipleFacet
- IntegrationTest_Chapters_MultipleFacet
steps:
- name: Checkout repository β
uses: actions/checkout@v6
- name: Set up Java 21 β
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- name: Cache CF CLI π¦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}
- name: Install Cloud Foundry CLI and jq π¦
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
echo "π§ Installing Cloud Foundry CLI..."
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli
- name: Install jq π¦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
- name: Login to Cloud Foundry π
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Logging in to Cloud Foundry using space: $CF_SPACE"
cf login -a "$CF_API" \
-u "$CF_USER" \
-p "$CF_PASSWORD" \
-o "$CF_ORG" \
-s $CF_SPACE > /dev/null
- name: Fetch and Escape Client Details for single tenant π
id: fetch_credentials
run: |
echo "Fetching client details for single tenant..."
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "β Error: clientSecret is not set or is null"; exit 1;
fi
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret"
clientID=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then
echo "β Error: clientID is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID"
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
echo "β
Client details fetched successfully!"
- name: Fetch and Escape Client Details for multi tenant π
id: fetch_credentials_mt
run: |
echo "Fetching client details for multi tenant..."
service_instance_guid=$(cf service bookshop-mt-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret_mt=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret_mt" ] || [ "$clientSecret_mt" == "null" ]; then
echo "β Error: clientSecret_mt is not set or is null"; exit 1;
fi
escapedClientSecret_mt=$(echo "$clientSecret_mt" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret_mt"
clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then
echo "β Error: clientID_mt is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID_mt"
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
echo "β
Multi-tenant client details fetched successfully!"
- name: Fetch and Escape SDM CMIS Credentials π
id: fetch_credentials_cmis
run: |
echo "π Fetching SDM CMIS credentials from CF service binding..."
service_instance_guid=$(cf service sdm --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve SDM service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
app_guid=$(cf app bookshop-mt-srv --guid)
binding_guid=$(echo "$bindings_response" | jq -r \
--arg app_guid "$app_guid" \
'.resources[] | select(.relationships.app.data.guid == $app_guid) | .guid' | head -1)
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve SDM binding GUID for bookshop-mt-srv"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
cmis_client_secret=$(echo "$binding_details" | jq -r '.credentials.uaa.clientsecret // .credentials.clientsecret // empty')
if [ -z "$cmis_client_secret" ] || [ "$cmis_client_secret" == "null" ]; then
echo "β Error: SDM clientsecret is not set or is null"; exit 1;
fi
echo "::add-mask::$cmis_client_secret"
cmis_client_id=$(echo "$binding_details" | jq -r '.credentials.uaa.clientid // .credentials.clientid // empty')
if [ -z "$cmis_client_id" ] || [ "$cmis_client_id" == "null" ]; then
echo "β Error: SDM clientid is not set or is null"; exit 1;
fi
echo "::add-mask::$cmis_client_id"
cmis_url=$(echo "$binding_details" | jq -r '.credentials.uri // .credentials.endpoints.ecm_service // .credentials.url // empty')
if [ -z "$cmis_url" ]; then
echo "β Error: SDM CMIS URL not found in binding details"; exit 1;
fi
echo "::add-mask::$cmis_url"
printf 'CMIS_CLIENT_SECRET=%s\n' "$cmis_client_secret" >> $GITHUB_OUTPUT
printf 'CMIS_CLIENT_ID=%s\n' "$cmis_client_id" >> $GITHUB_OUTPUT
printf 'CMIS_URL=%s\n' "$cmis_url" >> $GITHUB_OUTPUT
echo "β
SDM CMIS credentials fetched successfully!"
- name: Prepare credentials file π
env:
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
CMIS_CLIENT_ID: ${{ steps.fetch_credentials_cmis.outputs.CMIS_CLIENT_ID }}
CMIS_CLIENT_SECRET: ${{ steps.fetch_credentials_cmis.outputs.CMIS_CLIENT_SECRET }}
CMIS_URL_FROM_CF: ${{ steps.fetch_credentials_cmis.outputs.CMIS_URL }}
CF_ORG: ${{ secrets.CF_ORG }}
CAPAUTH_URL: ${{ secrets.CAPAUTH_URL }}
AUTHURLMT1: ${{ secrets.AUTHURLMT1 }}
AUTHURLMT2: ${{ secrets.AUTHURLMT2 }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
NOSDMROLEUSERNAME: ${{ secrets.NOSDMROLEUSERNAME }}
NOSDMROLEUSERPASSWORD: ${{ secrets.NOSDMROLEUSERPASSWORD }}
DEFAULTREPOSITORYID: ${{ secrets.DEFAULTREPOSITORYID }}
DEFAULTREPOSITORYIDMT: ${{ secrets.DEFAULTREPOSITORYIDMT }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
echo "π Preparing credentials for ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
set +x
set -e
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
appUrl="$CF_ORG-$CF_SPACE-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
appUrlMT="$CF_ORG-$CF_SPACE-bookshop-mt-srv.cfapps.eu12.hana.ondemand.com"
authUrl="$CAPAUTH_URL"
authUrlMT1="$AUTHURLMT1"
authUrlMT2="$AUTHURLMT2"
clientID="$CLIENT_ID"
clientSecret="$CLIENT_SECRET"
clientIDMT="$CLIENT_ID_MT"
clientSecretMT="$CLIENT_SECRET_MT"
username="$CF_USER"
password="$CF_PASSWORD"
noSDMRoleUsername="$NOSDMROLEUSERNAME"
noSDMRoleUserPassword="$NOSDMROLEUSERPASSWORD"
CMIS_URL="${{ env.CMIS_URL_FROM_CF }}"
cmisClientID="$CMIS_CLIENT_ID"
cmisClientSecret="$CMIS_CLIENT_SECRET"
defaultRepositoryID="$DEFAULTREPOSITORYID"
defaultRepositoryIDMT="$DEFAULTREPOSITORYIDMT"
echo "::add-mask::$clientSecret"
echo "::add-mask::$clientID"
echo "::add-mask::$clientSecretMT"
echo "::add-mask::$clientIDMT"
echo "::add-mask::$username"
echo "::add-mask::$password"
echo "::add-mask::$noSDMRoleUsername"
echo "::add-mask::$noSDMRoleUserPassword"
echo "::add-mask::$CMIS_URL"
echo "::add-mask::$cmisClientID"
echo "::add-mask::$cmisClientSecret"
if [ -z "$appUrl" ]; then echo "β Error: appUrl is not set"; exit 1; fi
if [ -z "$appUrlMT" ]; then echo "β Error: appUrlMT is not set"; exit 1; fi
if [ -z "$authUrl" ]; then echo "β Error: authUrl is not set"; exit 1; fi
if [ -z "$authUrlMT1" ]; then echo "β Error: authUrlMT1 is not set"; exit 1; fi
if [ -z "$authUrlMT2" ]; then echo "β Error: authUrlMT2 is not set"; exit 1; fi
if [ -z "$clientID" ]; then echo "β Error: clientID is not set"; exit 1; fi
if [ -z "$clientSecret" ]; then echo "β Error: clientSecret is not set"; exit 1; fi
if [ -z "$clientIDMT" ]; then echo "β Error: clientIDMT is not set"; exit 1; fi
if [ -z "$clientSecretMT" ]; then echo "β Error: clientSecretMT is not set"; exit 1; fi
if [ -z "$username" ]; then echo "β Error: username is not set"; exit 1; fi
if [ -z "$password" ]; then echo "β Error: password is not set"; exit 1; fi
if [ -z "$noSDMRoleUsername" ]; then echo "β Error: noSDMRoleUsername is not set"; exit 1; fi
if [ -z "$noSDMRoleUserPassword" ]; then echo "β Error: noSDMRoleUserPassword is not set"; exit 1; fi
if [ -z "$CMIS_URL" ]; then echo "β Error: CMIS_URL is not set"; exit 1; fi
if [ -z "$cmisClientID" ]; then echo "β Error: cmisClientID is not set"; exit 1; fi
if [ -z "$cmisClientSecret" ]; then echo "β Error: cmisClientSecret is not set"; exit 1; fi
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
appUrlMT=$appUrlMT
authUrl=$authUrl
authUrlMT1=$authUrlMT1
authUrlMT2=$authUrlMT2
clientID=$clientID
clientSecret=$clientSecret
clientIDMT=$clientIDMT
clientSecretMT=$clientSecretMT
username=$username
password=$password
noSDMRoleUsername=$noSDMRoleUsername
noSDMRoleUserPassword=$noSDMRoleUserPassword
CMIS_URL=$CMIS_URL
cmisClientID=$cmisClientID
cmisClientSecret=$cmisClientSecret
defaultRepositoryID=$defaultRepositoryID
defaultRepositoryIDMT=$defaultRepositoryIDMT
EOL
echo "β
Credentials file prepared!"
- name: Download virus test file π₯
run: |
curl -fSL "http://www.eicar.org/download/eicar.com.txt" -o "sdm/eicar.com.txt"
sleep 5
if [ -f "sdm/eicar.com.txt" ]; then
FILE_SIZE=$(stat -c '%s' "sdm/eicar.com.txt")
echo "File exists β Size: $FILE_SIZE bytes"
else
echo "β File NOT found at path: sdm/eicar.com.txt"
exit 1
fi
- name: Run integration tests (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}) π―
run: |
echo "π― Running Maven integration tests: testClass=${{ matrix.testClass }}, tokenFlow=${{ matrix.tokenFlow }}, tenant=${{ matrix.tenant }}"
MAX_RETRIES=3
ATTEMPT=0
EXIT_CODE=1
while [ $ATTEMPT -lt $MAX_RETRIES ]; do
ATTEMPT=$((ATTEMPT + 1))
echo "π Attempt $ATTEMPT of $MAX_RETRIES..."
if mvn clean verify -P integration-tests -DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} -DskipUnitTests -Deicar.file.path=eicar.com.txt -Dfailsafe.includes="**/${{ matrix.testClass }}.java"; then
echo "β
Tests passed on attempt $ATTEMPT!"
EXIT_CODE=0
break
else
if [ $ATTEMPT -lt $MAX_RETRIES ]; then
echo "β οΈ Attempt $ATTEMPT failed. Retrying in 30 seconds..."
sleep 30
else
echo "β All $MAX_RETRIES attempts failed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}."
fi
fi
done
exit $EXIT_CODE
- name: Upload test results π
if: "!cancelled()"
uses: actions/upload-artifact@v4
with:
name: test-results-${{ matrix.testClass }}-${{ matrix.tokenFlow }}-${{ matrix.tenant }}
path: |
sdm/target/surefire-reports/
sdm/target/failsafe-reports/
retention-days: 7
# Single-job setup: switch CF app to versioned repo BEFORE matrix tests run.
# Avoids race condition where parallel matrix entries try to restage the same app simultaneously.
versioned-setup:
environment: dev
runs-on: ubuntu-latest
needs: integration-test
steps:
- name: Cache CF CLI π¦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}
- name: Install Cloud Foundry CLI π§
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli
- name: Install jq π¦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
- name: Login to Cloud Foundry π
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Logging in to Cloud Foundry using space: $CF_SPACE"
cf login -a "$CF_API" \
-u "$CF_USER" \
-p "$CF_PASSWORD" \
-o "$CF_ORG" \
-s $CF_SPACE > /dev/null
- name: Switch to versioned repository π
env:
VERSIONEDREPOSITORYID: ${{ secrets.VERSIONEDREPOSITORYID }}
run: |
APP_GUID=$(cf app bookshop-mt-srv --guid)
CURRENT=$(cf curl "/v3/apps/${APP_GUID}/environment_variables" | jq -r '.var.REPOSITORY_ID // empty')
if [ "$CURRENT" != "$VERSIONEDREPOSITORYID" ]; then
echo "π Switching REPOSITORY_ID to versioned repository..."
cf set-env bookshop-mt-srv REPOSITORY_ID "$VERSIONEDREPOSITORYID"
echo "π Restaging application..."
cf restage bookshop-mt-srv > /dev/null 2>&1
echo "β
Switched to versioned repository!"
else
echo "β
Repository already set to versioned, skipping restage"
fi
# Versioned tests run in parallel against the already-switched repo
# Skipped if integration-test or versioned-setup fails
versioned-test:
environment: dev
runs-on: ubuntu-latest
needs: versioned-setup
strategy:
fail-fast: false
matrix:
tokenFlow: [namedUser, technicalUser]
tenant: [TENANT1, TENANT2]
testClass:
- IntegrationTest_SingleFacet_VersionedRepository
- IntegrationTest_MultipleFacet_VersionedRepository
- IntegrationTest_Chapters_MultipleFacet_VersionedRepository
steps:
- name: Checkout repository π
uses: actions/checkout@v6
- name: Set up Java 17 β
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Cache CF CLI π¦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}
- name: Install Cloud Foundry CLI π§
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli
- name: Install jq π¦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
- name: Login to Cloud Foundry π
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Logging in to Cloud Foundry using space: $CF_SPACE"
cf login -a "$CF_API" \
-u "$CF_USER" \
-p "$CF_PASSWORD" \
-o "$CF_ORG" \
-s $CF_SPACE > /dev/null
- name: Fetch and Escape Client Details for single tenant π
id: fetch_credentials
run: |
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "β Error: clientSecret is not set or is null"; exit 1;
fi
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret"
clientID=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then
echo "β Error: clientID is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID"
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
- name: Fetch and Escape Client Details for multi tenant π
id: fetch_credentials_mt
run: |
service_instance_guid=$(cf service bookshop-mt-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret_mt=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret_mt" ] || [ "$clientSecret_mt" == "null" ]; then
echo "β Error: clientSecret_mt is not set or is null"; exit 1;
fi
escapedClientSecret_mt=$(echo "$clientSecret_mt" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret_mt"
clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then
echo "β Error: clientID_mt is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID_mt"
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
- name: Fetch and Escape SDM CMIS Credentials π
id: fetch_credentials_cmis
run: |
echo "π Fetching SDM CMIS credentials from CF service binding..."
service_instance_guid=$(cf service sdm --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve SDM service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
app_guid=$(cf app bookshop-mt-srv --guid)
binding_guid=$(echo "$bindings_response" | jq -r \
--arg app_guid "$app_guid" \
'.resources[] | select(.relationships.app.data.guid == $app_guid) | .guid' | head -1)
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve SDM binding GUID for bookshop-mt-srv"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
cmis_client_secret=$(echo "$binding_details" | jq -r '.credentials.uaa.clientsecret // .credentials.clientsecret // empty')
if [ -z "$cmis_client_secret" ] || [ "$cmis_client_secret" == "null" ]; then
echo "β Error: SDM clientsecret is not set or is null"; exit 1;
fi
echo "::add-mask::$cmis_client_secret"
cmis_client_id=$(echo "$binding_details" | jq -r '.credentials.uaa.clientid // .credentials.clientid // empty')
if [ -z "$cmis_client_id" ] || [ "$cmis_client_id" == "null" ]; then
echo "β Error: SDM clientid is not set or is null"; exit 1;
fi
echo "::add-mask::$cmis_client_id"
cmis_url=$(echo "$binding_details" | jq -r '.credentials.uri // .credentials.endpoints.ecm_service // .credentials.url // empty')
if [ -z "$cmis_url" ]; then
echo "β Error: SDM CMIS URL not found in binding details"; exit 1;
fi
echo "::add-mask::$cmis_url"
printf 'CMIS_CLIENT_SECRET=%s\n' "$cmis_client_secret" >> $GITHUB_OUTPUT
printf 'CMIS_CLIENT_ID=%s\n' "$cmis_client_id" >> $GITHUB_OUTPUT
printf 'CMIS_URL=%s\n' "$cmis_url" >> $GITHUB_OUTPUT
echo "β
SDM CMIS credentials fetched successfully!"
- name: Run versioned integration tests π― (${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }})
env:
CLIENT_SECRET: ${{ steps.fetch_credentials.outputs.CLIENT_SECRET }}
CLIENT_ID: ${{ steps.fetch_credentials.outputs.CLIENT_ID }}
CLIENT_SECRET_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_SECRET_MT }}
CLIENT_ID_MT: ${{ steps.fetch_credentials_mt.outputs.CLIENT_ID_MT }}
CMIS_CLIENT_ID: ${{ steps.fetch_credentials_cmis.outputs.CMIS_CLIENT_ID }}
CMIS_CLIENT_SECRET: ${{ steps.fetch_credentials_cmis.outputs.CMIS_CLIENT_SECRET }}
CMIS_URL_FROM_CF: ${{ steps.fetch_credentials_cmis.outputs.CMIS_URL }}
CF_ORG: ${{ secrets.CF_ORG }}
CAPAUTH_URL: ${{ secrets.CAPAUTH_URL }}
AUTHURLMT1: ${{ secrets.AUTHURLMT1 }}
AUTHURLMT2: ${{ secrets.AUTHURLMT2 }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
NOSDMROLEUSERNAME: ${{ secrets.NOSDMROLEUSERNAME }}
NOSDMROLEUSERPASSWORD: ${{ secrets.NOSDMROLEUSERPASSWORD }}
VERSIONEDREPOSITORYID: ${{ secrets.VERSIONEDREPOSITORYID }}
VIRUSSCANREPOSITORYID: ${{ secrets.VIRUSSCANREPOSITORYID }}
DEFAULTREPOSITORYID: ${{ secrets.DEFAULTREPOSITORYID }}
DEFAULTREPOSITORYIDMT: ${{ secrets.DEFAULTREPOSITORYIDMT }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set -e
PROPERTIES_FILE="sdm/src/test/resources/credentials.properties"
appUrl="$CF_ORG-$CF_SPACE-demoappjava-srv.cfapps.eu12.hana.ondemand.com"
appUrlMT="$CF_ORG-$CF_SPACE-bookshop-mt-srv.cfapps.eu12.hana.ondemand.com"
authUrl="$CAPAUTH_URL"
authUrlMT1="$AUTHURLMT1"
authUrlMT2="$AUTHURLMT2"
clientID="$CLIENT_ID"
clientSecret="$CLIENT_SECRET"
clientIDMT="$CLIENT_ID_MT"
clientSecretMT="$CLIENT_SECRET_MT"
username="$CF_USER"
password="$CF_PASSWORD"
noSDMRoleUsername="$NOSDMROLEUSERNAME"
noSDMRoleUserPassword="$NOSDMROLEUSERPASSWORD"
versionedRepositoryID="$VERSIONEDREPOSITORYID"
virusScanRepositoryID="$VIRUSSCANREPOSITORYID"
defaultRepositoryID="$DEFAULTREPOSITORYID"
defaultRepositoryIDMT="$DEFAULTREPOSITORYIDMT"
CMIS_URL="$CMIS_URL_FROM_CF"
cmisClientID="$CMIS_CLIENT_ID"
cmisClientSecret="$CMIS_CLIENT_SECRET"
cat > "$PROPERTIES_FILE" <<EOL
appUrl=$appUrl
appUrlMT=$appUrlMT
authUrl=$authUrl
authUrlMT1=$authUrlMT1
authUrlMT2=$authUrlMT2
clientID=$clientID
clientSecret=$clientSecret
clientIDMT=$clientIDMT
clientSecretMT=$clientSecretMT
username=$username
password=$password
noSDMRoleUsername=$noSDMRoleUsername
noSDMRoleUserPassword=$noSDMRoleUserPassword
versionedRepositoryID=$versionedRepositoryID
virusScanRepositoryID=$virusScanRepositoryID
defaultRepositoryID=$defaultRepositoryID
defaultRepositoryIDMT=$defaultRepositoryIDMT
CMIS_URL=$CMIS_URL
cmisClientID=$cmisClientID
cmisClientSecret=$cmisClientSecret
EOL
echo "π― Running versioned integration tests for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}..."
MAX_RETRIES=3
ATTEMPT=0
EXIT_CODE=1
while [ $ATTEMPT -lt $MAX_RETRIES ]; do
ATTEMPT=$((ATTEMPT + 1))
echo "π Attempt $ATTEMPT of $MAX_RETRIES..."
if mvn clean verify -P integration-tests \
-DtokenFlow=${{ matrix.tokenFlow }} -DtenancyModel=multi -Dtenant=${{ matrix.tenant }} \
-DskipUnitTests -Dfailsafe.includes="**/${{ matrix.testClass }}.java"; then
echo "β
Tests passed on attempt $ATTEMPT!"
EXIT_CODE=0
break
else
if [ $ATTEMPT -lt $MAX_RETRIES ]; then
echo "β οΈ Attempt $ATTEMPT failed. Retrying in 30 seconds..."
sleep 30
else
echo "β All $MAX_RETRIES attempts failed for ${{ matrix.testClass }} - ${{ matrix.tokenFlow }} - ${{ matrix.tenant }}."
fi
fi
done
exit $EXIT_CODE
# Single-job setup: switch CF app to virus scan repo BEFORE matrix tests run.
# Avoids race condition where parallel matrix entries try to restage the same app simultaneously.
virusscan-setup:
environment: dev
runs-on: ubuntu-latest
needs: versioned-test
steps:
- name: Cache CF CLI π¦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}
- name: Install Cloud Foundry CLI π§
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli
- name: Install jq π¦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
- name: Login to Cloud Foundry π
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Logging in to Cloud Foundry using space: $CF_SPACE"
cf login -a "$CF_API" \
-u "$CF_USER" \
-p "$CF_PASSWORD" \
-o "$CF_ORG" \
-s $CF_SPACE > /dev/null
- name: Switch to virus scan repository π
env:
VIRUSSCANREPOSITORYID: ${{ secrets.VIRUSSCANREPOSITORYID }}
run: |
APP_GUID=$(cf app bookshop-mt-srv --guid)
CURRENT=$(cf curl "/v3/apps/${APP_GUID}/environment_variables" | jq -r '.var.REPOSITORY_ID // empty')
if [ "$CURRENT" != "$VIRUSSCANREPOSITORYID" ]; then
echo "π Switching REPOSITORY_ID to virus scan repository..."
cf set-env bookshop-mt-srv REPOSITORY_ID "$VIRUSSCANREPOSITORYID"
echo "π Restaging application..."
cf restage bookshop-mt-srv > /dev/null 2>&1
echo "β
Switched to virus scan repository!"
else
echo "β
Repository already set to virus scan, skipping restage"
fi
# Virus scan tests run in parallel against the already-switched repo
# Skipped if versioned-test or virusscan-setup fails
virusscan-test:
environment: dev
runs-on: ubuntu-latest
needs: virusscan-setup
strategy:
fail-fast: false
matrix:
tokenFlow: [namedUser, technicalUser]
tenant: [TENANT1, TENANT2]
testClass:
- IntegrationTest_SingleFacet_Virus
- IntegrationTest_MultipleFacet_Virus
- IntegrationTest_Chapters_MultipleFacet_Virus
steps:
- name: Checkout repository π
uses: actions/checkout@v6
- name: Set up Java 17 β
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Cache CF CLI π¦
id: cache-cf-cli
uses: actions/cache@v4
with:
path: /usr/bin/cf8
key: cf-cli-v8-${{ runner.os }}
- name: Install Cloud Foundry CLI π§
if: steps.cache-cf-cli.outputs.cache-hit != 'true'
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
sudo apt-get update
sudo apt-get install cf8-cli
- name: Install jq π¦
run: |
if ! command -v jq &> /dev/null; then
sudo apt-get update && sudo apt-get install -y jq
fi
- name: Login to Cloud Foundry π
env:
CF_API: ${{ secrets.CF_API }}
CF_USER: ${{ secrets.CF_USER }}
CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE }}
run: |
set +x
echo "::add-mask::$CF_API"
echo "::add-mask::$CF_USER"
echo "::add-mask::$CF_PASSWORD"
echo "::add-mask::$CF_ORG"
echo "::add-mask::$CF_SPACE"
echo "π Logging in to Cloud Foundry using space: $CF_SPACE"
cf login -a "$CF_API" \
-u "$CF_USER" \
-p "$CF_PASSWORD" \
-o "$CF_ORG" \
-s $CF_SPACE > /dev/null
- name: Fetch and Escape Client Details for single tenant π
id: fetch_credentials
run: |
service_instance_guid=$(cf service demoappjava-public-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret" ] || [ "$clientSecret" == "null" ]; then
echo "β Error: clientSecret is not set or is null"; exit 1;
fi
escapedClientSecret=$(echo "$clientSecret" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret"
clientID=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID" ] || [ "$clientID" == "null" ]; then
echo "β Error: clientID is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID"
echo "CLIENT_SECRET=$escapedClientSecret" >> $GITHUB_OUTPUT
echo "CLIENT_ID=$clientID" >> $GITHUB_OUTPUT
- name: Fetch and Escape Client Details for multi tenant π
id: fetch_credentials_mt
run: |
service_instance_guid=$(cf service bookshop-mt-uaa --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")
binding_guid=$(echo "$bindings_response" | jq -r '.resources[0].guid')
if [ -z "$binding_guid" ]; then
echo "β Error: Unable to retrieve binding GUID"; exit 1;
fi
binding_details=$(cf curl "/v3/service_credential_bindings/${binding_guid}/details")
clientSecret_mt=$(echo "$binding_details" | jq -r '.credentials.clientsecret')
if [ -z "$clientSecret_mt" ] || [ "$clientSecret_mt" == "null" ]; then
echo "β Error: clientSecret_mt is not set or is null"; exit 1;
fi
escapedClientSecret_mt=$(echo "$clientSecret_mt" | sed 's/\$/\\$/g')
echo "::add-mask::$escapedClientSecret_mt"
clientID_mt=$(echo "$binding_details" | jq -r '.credentials.clientid')
if [ -z "$clientID_mt" ] || [ "$clientID_mt" == "null" ]; then
echo "β Error: clientID_mt is not set or is null"; exit 1;
fi
echo "::add-mask::$clientID_mt"
echo "CLIENT_SECRET_MT=$escapedClientSecret_mt" >> $GITHUB_OUTPUT
echo "CLIENT_ID_MT=$clientID_mt" >> $GITHUB_OUTPUT
- name: Fetch and Escape SDM CMIS Credentials π
id: fetch_credentials_cmis
run: |
echo "π Fetching SDM CMIS credentials from CF service binding..."
service_instance_guid=$(cf service sdm --guid)
if [ -z "$service_instance_guid" ]; then
echo "β Error: Unable to retrieve SDM service instance GUID"; exit 1;
fi
bindings_response=$(cf curl "/v3/service_credential_bindings?service_instance_guids=${service_instance_guid}")