@@ -92,10 +92,18 @@ jobs:
9292 echo "[ERROR] Release tags must be semantic versions, for example v1.2.3."
9393 exit 1
9494 fi
95- release_json=$(gh release view "$source_value" --repo "$GITHUB_REPOSITORY" --json assets)
95+ if ! release_json=$(gh release view "$source_value" --repo "$GITHUB_REPOSITORY" --json assets 2>&1); then
96+ echo "[ERROR] Release '$source_value' not found in repository."
97+ echo "$release_json"
98+ exit 1
99+ fi
96100 is_release="true"
97101 elif [[ "$source_type" == "branch" ]]; then
98- branch_matches=$(gh api "repos/${GITHUB_REPOSITORY}/git/matching-refs/heads/${source_value}" --jq 'length')
102+ if ! branch_matches=$(gh api "repos/${GITHUB_REPOSITORY}/git/matching-refs/heads/${source_value}" --jq 'length' 2>&1); then
103+ echo "[ERROR] Failed to check branch '$source_value'."
104+ echo "$branch_matches"
105+ exit 1
106+ fi
99107 if [[ "$branch_matches" -eq 0 ]]; then
100108 echo "[ERROR] Branch '$source_value' not found in repository."
101109 exit 1
@@ -105,6 +113,19 @@ jobs:
105113 exit 1
106114 fi
107115
116+ # --- Cross-validation (only when deploying both) ---
117+
118+ if [[ "$deploy_backend" == "true" && "$deploy_proxy" == "true" ]]; then
119+ case "${backend_account_group}:${apim_environment}" in
120+ dev:internal-dev|nonprod:int|prod:prod) ;;
121+ *)
122+ echo "[ERROR] Mismatched backend/APIM pair: '${backend_account_group}' and '${apim_environment}'."
123+ echo "[ERROR] Valid combinations: dev/internal-dev, nonprod/int, prod/prod."
124+ exit 1
125+ ;;
126+ esac
127+ fi
128+
108129 # --- Backend validation (only when deploying backend) ---
109130
110131 target_account_group=""
@@ -148,21 +169,13 @@ jobs:
148169
149170 if [[ "$is_release" == "true" ]]; then
150171 oas_asset="api-oas-specification-${apim_environment}-${source_value}.zip"
151- echo "$release_json" | jq -r '.assets[].name' | grep -x "$oas_asset" >/dev/null
152- fi
153- fi
154-
155- # --- Cross-validation (only when deploying both) ---
156-
157- if [[ "$deploy_backend" == "true" && "$deploy_proxy" == "true" ]]; then
158- case "${backend_account_group}:${apim_environment}" in
159- dev:internal-dev|nonprod:int|prod:prod) ;;
160- *)
161- echo "[ERROR] Mismatched backend/APIM pair: '${backend_account_group}' and '${apim_environment}'."
162- echo "[ERROR] Valid combinations: dev/internal-dev, nonprod/int, prod/prod."
172+ if ! echo "$release_json" | jq -r '.assets[].name' | grep -qx "$oas_asset"; then
173+ echo "[ERROR] Release '$source_value' does not contain required OAS asset '$oas_asset'."
174+ echo "Available assets:"
175+ echo "$release_json" | jq -r '.assets[].name'
163176 exit 1
164- ;;
165- esac
177+ fi
178+ fi
166179 fi
167180
168181 build_artifact_version=""
0 commit comments