Skip to content

Commit d66570a

Browse files
authored
Merge pull request #3730 from PolicyEngine/fix/staging-cloud-run-tag-length
Fit staging Cloud Run tag within the 46-char combined limit
2 parents 7110f23 + 4908878 commit d66570a

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

.github/scripts/validate_cloud_run_deploy_env.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ set -euo pipefail
55
source .github/scripts/cloud_run_env.sh
66
cloud_run_set_defaults
77

8+
# Cloud Run rejects deploys where the traffic tag and service name together
9+
# exceed 46 characters (they form the tag URL's DNS label). Fail fast here
10+
# with a clear message instead of at gcloud.
11+
combined_length=$(( ${#CLOUD_RUN_TAG} + ${#CLOUD_RUN_SERVICE} ))
12+
if (( combined_length > 46 )); then
13+
echo "Cloud Run tag '${CLOUD_RUN_TAG}' (${#CLOUD_RUN_TAG}) + service '${CLOUD_RUN_SERVICE}' (${#CLOUD_RUN_SERVICE}) = ${combined_length} characters exceeds Cloud Run's 46-character combined limit." >&2
14+
exit 1
15+
fi
16+
817
cloud_run_require_env \
918
CLOUD_RUN_PROJECT \
1019
CLOUD_RUN_REGION \

.github/workflows/push.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ jobs:
233233
id: cloud_run
234234
run: |
235235
echo "image_tag=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
236-
echo "revision_tag=stage3-staging-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
236+
# Short tag: Cloud Run caps tag + service name at 46 combined chars.
237+
echo "revision_tag=stg-${GITHUB_RUN_NUMBER}-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
237238
- name: Build and push Cloud Run image
238239
run: bash .github/scripts/build_cloud_run_image.sh
239240
env:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Shorten the staging Cloud Run revision tag to fit Cloud Run's 46-character combined tag + service name limit, and fail fast in deploy validation when the limit is exceeded.

0 commit comments

Comments
 (0)