Skip to content

Commit

Permalink
Add a build trigger that updates CDC stable images (datacommonsorg#4736)
Browse files Browse the repository at this point in the history
- Since this only depends on website repo, it doesn't need to live in
the deployment repo (and it would add complexity to have to update a
version file and have it live there)
- I've factored out commit label construction into a shared helper too
- Note that the website portion of the stable image's commits label will
be a merge commit that only exists on the stable branch.
  • Loading branch information
hqpho authored Nov 14, 2024
1 parent d8dd40c commit d571bbc
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 8 deletions.
70 changes: 70 additions & 0 deletions build/ci/cloudbuild.push_cdc_stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2024 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.

# Updates stable-tagged Docker images for custom DC.
# Assumes the stable branch is already checked out, which it should be
# if this is triggered on push to branch for the stable branch.

steps:
# Step 0: Initialize submods
- id: init-submods
name: gcr.io/cloud-builders/git
entrypoint: bash
args:
- -c
- |
set -e
git submodule update --init --recursive
waitFor: ["-"]

# Step 1: Get a label that combines commit hashes.
- id: get-label
name: gcr.io/cloud-builders/git
entrypoint: bash
args:
- -c
- |
set -e
./scripts/get_commits_label.sh | tail -1 >"$_IMAGE_LABEL_PATH"
waitFor: ["init-submods"]

# Step 1: Services container
- id: build-and-tag-stable-services
name: gcr.io/datcom-ci/deploy-tool
entrypoint: bash
args:
- -c
- |
set -e
image_label=$(cat "$_IMAGE_LABEL_PATH")
./scripts/build_cdc_services_and_tag_stable.sh $image_label
waitFor: ["get-label"]

# Step 2: Data management container
- id: build-and-tag-stable-data
name: gcr.io/datcom-ci/deploy-tool
entrypoint: bash
args:
- -c
- |
set -e
image_label=$(cat "$_IMAGE_LABEL_PATH")
./scripts/build_cdc_data_and_tag_stable.sh $image_label
waitFor: ["get-label"]

substitutions:
_IMAGE_LABEL_PATH: "/workspace/tmp_cdc_stable_image_label.txt"

options:
machineType: "E2_HIGHCPU_32"
29 changes: 29 additions & 0 deletions scripts/get_commits_label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Copyright 2024 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.

# Make a label for container images using the combined commit hash of website
# and its submods.

# Optionally use the commit before HEAD for the main repo.
if [[ "$1" == "--head-is-temporary" ]]; then
website_rev="$(git rev-parse --short HEAD~1)"
else
website_rev="$(git rev-parse --short HEAD)"
fi
mixer_rev="$(git rev-parse --short HEAD:mixer)"
import_rev="$(git rev-parse --short HEAD:import)"
image_label="${website_rev}-${mixer_rev}-${import_rev}"

echo "$image_label"
9 changes: 1 addition & 8 deletions scripts/update_submods_for_cdc_autopush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
set -e
set -x

# Get the website short commit hash before it changes due to a temp commit.
website_rev="$(git rev-parse --short HEAD)"

# Initialize all submodules, then merge them with their masters and update
# their pinned versions (locally only).
./scripts/update_git_submodules.sh
Expand All @@ -36,8 +33,4 @@ git config user.email "$(gcloud auth list --filter=status:ACTIVE --format='value

git commit --allow-empty -am "DO NOT PUSH: Temp commit to update pinned submod versions (empty if submods are already up-to-date)"

mixer_rev="$(git rev-parse --short HEAD:mixer)"
import_rev="$(git rev-parse --short HEAD:import)"
image_label="${website_rev}-${mixer_rev}-${import_rev}"

echo "$image_label"
./scripts/get_commits_label.sh --head-is-temporary

0 comments on commit d571bbc

Please sign in to comment.