Skip to content

Commit b41cdef

Browse files
committed
ci(v12-pipeline): fix version scoping and schedule quoting bug
1 parent 27e4e8d commit b41cdef

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

.github/workflows/v12-deployment-pipeline.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,19 +572,32 @@ jobs:
572572
ENVIRONMENT: ${{ needs.setup_deployment.outputs.environment }}
573573
TAG: ${{ needs.setup_deployment.outputs.tag }}
574574
CM_URL: ${{ needs.setup_deployment.outputs.cm_url }}
575+
SCHEDULE_INSTANCES_DEV: ${{ vars.SCHEDULE_INSTANCES_DEV }}
576+
SCHEDULE_INSTANCES_PROD: ${{ vars.SCHEDULE_INSTANCES_PROD }}
577+
CM_AUTH_DEV: ${{ secrets.CM_SERVICE_ACCOUNT_DEV }}
578+
CM_AUTH_PROD: ${{ secrets.CM_SERVICE_ACCOUNT_PROD }}
575579
steps:
576580
- name: Schedule updates
577581
run: |
578582
echo "🔍 Environment: $ENVIRONMENT"
579583
echo "🔍 Version: $TAG"
580584
echo "🔍 CM URL: $CM_URL"
581585
586+
# Values are passed in via `env:` (not interpolated directly into this
587+
# script) so embedded quotes in the JSON can't corrupt the shell parsing.
582588
if [ "$ENVIRONMENT" = "dev" ]; then
583-
targets_json="${{ vars.SCHEDULE_INSTANCES_DEV }}"
584-
auth_json='${{ secrets.CM_SERVICE_ACCOUNT_DEV }}'
589+
targets_json="$SCHEDULE_INSTANCES_DEV"
590+
auth_json="$CM_AUTH_DEV"
591+
targets_var_name="SCHEDULE_INSTANCES_DEV"
585592
else
586-
targets_json="${{ vars.SCHEDULE_INSTANCES_PROD }}"
587-
auth_json='${{ secrets.CM_SERVICE_ACCOUNT_PROD }}'
593+
targets_json="$SCHEDULE_INSTANCES_PROD"
594+
auth_json="$CM_AUTH_PROD"
595+
targets_var_name="SCHEDULE_INSTANCES_PROD"
596+
fi
597+
598+
if ! echo "$targets_json" | jq empty > /dev/null 2>&1; then
599+
echo "❌ $targets_var_name is not valid JSON: $targets_json"
600+
exit 1
588601
fi
589602
590603
# Extract id and key from auth JSON
@@ -593,6 +606,7 @@ jobs:
593606
594607
# Targets are grouped by product_id (CM scopes instances/versions by
595608
# product and /api/v1/updates requires it): {"<product_id>": ["<instance_id>", ...]}
609+
scheduled=0
596610
for product_id in $(echo "$targets_json" | jq -r 'keys[]'); do
597611
for instance_id in $(echo "$targets_json" | jq -r --arg p "$product_id" '.[$p][]'); do
598612
echo "📅 Scheduling release for instance: $instance_id (product: $product_id)"
@@ -608,6 +622,7 @@ jobs:
608622
609623
if [ "$http_code" -ge 200 ] && [ "$http_code" -lt 300 ]; then
610624
echo "✅ Successfully scheduled for instance: $instance_id"
625+
scheduled=$((scheduled + 1))
611626
else
612627
echo "❌ Failed to schedule for instance: $instance_id (HTTP $http_code)"
613628
echo "Response: $body"
@@ -616,4 +631,9 @@ jobs:
616631
done
617632
done
618633
619-
echo "✅ Scheduled release for all instances with version $TAG"
634+
if [ "$scheduled" -eq 0 ]; then
635+
echo "❌ No instances were scheduled — check $targets_var_name"
636+
exit 1
637+
fi
638+
639+
echo "✅ Scheduled release for all $scheduled instance(s) with version $TAG"

0 commit comments

Comments
 (0)