Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions build/ci/cloudbuild.deploy_cdc_autopush.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args:
- 'run'
- 'deploy'
- 'dc-autopush'
- '--project'
- 'datcom-website-dev'
- '--image'
- 'gcr.io/datcom-ci/datacommons-services:latest'
- '--region'
- 'us-central1'
- '--update-env-vars'
- 'RESTART_TIMESTAMP=$BUILD_ID'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Use the Cloud Build substitution syntax ${BUILD_ID} to ensure the variable is expanded by the Cloud Build service. Since the gcloud entrypoint does not invoke a shell to process arguments, using $BUILD_ID will result in the literal string "$BUILD_ID" being set as the environment variable value in Cloud Run, which breaks the intended audit functionality.

      - 'RESTART_TIMESTAMP=${BUILD_ID}'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems right

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.


tags:
- 'cloudrun--dc-autopush'
15 changes: 5 additions & 10 deletions scripts/deploy_cdc_services_latest_to_autopush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Deploys the custom DC services image tagged "latest" to the dc-autopush service.
# Deploys the custom DC services image tagged "latest" to the dc-autopush service securely via Cloud Build.

# The script also updates a RESTART_TIMESTAMP env var
# to easily identify the restart time of a given revision.
# The script natively inherits a dynamic RESTART_TIMESTAMP env var internally
# generated by Cloud Build using the exact $BUILD_ID to easily audit revisions.

# Usage: From root, ./scripts/deploy_cdc_services_latest_to_autopush.sh

# The latest image = gcr.io/datcom-ci/datacommons-services:latest
# The deployed image = gcr.io/datcom-ci/datacommons-services:latest
# autopush service: https://pantheon.corp.google.com/run/detail/us-central1/dc-autopush/revisions?project=datcom-website-dev
# autopush URL: https://dc-autopush-496370955550.us-central1.run.app

set -e
set -x

# Deploy latest image to dc-autopush Cloud Run service
gcloud run deploy dc-autopush \
--project datcom-website-dev \
--image gcr.io/datcom-ci/datacommons-services:latest \
--region us-central1 \
--update-env-vars RESTART_TIMESTAMP="$(date)"
gcloud builds submit --config build/ci/cloudbuild.deploy_cdc_autopush.yaml --project datcom-ci .
Comment thread
gmechali marked this conversation as resolved.
Outdated
Loading