From e05a2cbf255ab0c90c71ddad212472e3153e04eb Mon Sep 17 00:00:00 2001 From: Sanjay Vasandani Date: Thu, 4 May 2023 14:20:06 -0700 Subject: [PATCH] Add workflow for updating CMMS deployment. --- .github/workflows/configure-duchy.yml | 15 ++--- .github/workflows/configure-kingdom.yml | 2 +- .github/workflows/export-duchy-cert-id.sh | 34 ++++++++++ .github/workflows/update-cmms-dev.yml | 28 ++++++++ .github/workflows/update-cmms.yml | 80 +++++++++++++++++++++++ 5 files changed, 148 insertions(+), 11 deletions(-) create mode 100755 .github/workflows/export-duchy-cert-id.sh create mode 100644 .github/workflows/update-cmms-dev.yml create mode 100644 .github/workflows/update-cmms.yml diff --git a/.github/workflows/configure-duchy.yml b/.github/workflows/configure-duchy.yml index 0d2a55374d5..b69c4b239ff 100644 --- a/.github/workflows/configure-duchy.yml +++ b/.github/workflows/configure-duchy.yml @@ -28,14 +28,10 @@ on: description: "Name (external ID) of Duchy" type: string required: true - duchy-cert-id: - description: "ID of the Duchy certificate" - type: string - required: true apply: description: "Apply the new configuration" type: boolean - default: true + required: true workflow_dispatch: inputs: environment: @@ -55,10 +51,6 @@ on: - worker2 - aggregator required: true - duchy-cert-id: - description: "ID of the Duchy certificate" - type: string - required: true apply: description: "Apply the new configuration" type: boolean @@ -86,13 +78,15 @@ jobs: workload_identity_provider: ${{ vars.WORKLOAD_IDENTITY_PROVIDER }} service_account: ${{ vars.GKE_CONFIG_SERVICE_ACCOUNT }} + - name: Export DUCHY_CERT_ID + run: ./.github/workflows/export-duchy-cert-id.sh + - name: Generate archives env: IMAGE_TAG: ${{ inputs.image-tag }} SPANNER_INSTANCE: ${{ vars.SPANNER_INSTANCE }} KINGDOM_SYSTEM_API_TARGET: ${{ vars.KINGDOM_SYSTEM_API_TARGET }} DUCHY_STORAGE_BUCKET: ${{ vars.DUCHY_STORAGE_BUCKET }} - DUCHY_CERT_ID: ${{ inputs.duchy-cert-id }} run: > bazelisk build "//src/main/k8s/dev:${DUCHY_NAME}_duchy.tar" @@ -105,6 +99,7 @@ jobs: --define "duchy_storage_bucket=$DUCHY_STORAGE_BUCKET" --define "duchy_cert_id=$DUCHY_CERT_ID" + - name: Make Kustomization dir run: mkdir -p "$KUSTOMIZATION_PATH" diff --git a/.github/workflows/configure-kingdom.yml b/.github/workflows/configure-kingdom.yml index d94590cc009..f73346ce821 100644 --- a/.github/workflows/configure-kingdom.yml +++ b/.github/workflows/configure-kingdom.yml @@ -27,7 +27,7 @@ on: apply: description: "Apply the new configuration" type: boolean - default: true + required: true workflow_dispatch: inputs: environment: diff --git a/.github/workflows/export-duchy-cert-id.sh b/.github/workflows/export-duchy-cert-id.sh new file mode 100755 index 00000000000..c63450360ad --- /dev/null +++ b/.github/workflows/export-duchy-cert-id.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Copyright 2023 The Cross-Media Measurement Authors +# +# 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 +# +# http://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. + + +declare duchy_cert_id +case "$DUCHY_NAME" in + aggregator) + duchy_cert_id="$AGGREGATOR_DUCHY_CERT_ID" + ;; + worker1) + duchy_cert_id="$WORKER1_DUCHY_CERT_ID" + ;; + worker2) + duchy_cert_id="$WORKER2_DUCHY_CERT_ID" + ;; + *) + echo "Unexpected Duchy name $DUCHY_NAME" >&2 + exit 1 + ;; +esac + +echo "DUCHY_CERT_ID=${duchy_cert_id}" >> "$GITHUB_ENV" diff --git a/.github/workflows/update-cmms-dev.yml b/.github/workflows/update-cmms-dev.yml new file mode 100644 index 00000000000..b3788385739 --- /dev/null +++ b/.github/workflows/update-cmms-dev.yml @@ -0,0 +1,28 @@ +# Copyright 2023 The Cross-Media Measurement Authors +# +# 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 +# +# http://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. + +name: Update CMMS on dev environment + +on: + release: + types: [published] + pull_request: # DEBUG + types: [ opened, synchronize, edited ] + +jobs: + update-cmms: + uses: ./.github/workflows/update-cmms.yml + with: + environment: dev + apply: false # DEBUG diff --git a/.github/workflows/update-cmms.yml b/.github/workflows/update-cmms.yml new file mode 100644 index 00000000000..65444e24e7f --- /dev/null +++ b/.github/workflows/update-cmms.yml @@ -0,0 +1,80 @@ +# Copyright 2023 The Cross-Media Measurement Authors +# +# 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 +# +# http://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. + +name: Update CMMS + +on: + workflow_call: + inputs: + environment: + type: string + required: true + apply: + description: "Apply the new configuration" + type: boolean + required: true + workflow_dispatch: + inputs: + environment: + required: true + type: choice + options: + - dev + apply: + description: "Apply the new configuration" + type: boolean + default: false + +jobs: + publish-images: + uses: ./.github/workflows/create-cmm-images.yml + + # TODO(@SanjayVas): Call Terraforming workflows. + + update-kingdom: + uses: ./.github/workflows/configure-kingdom.yml + needs: publish-images + with: + image-tag: ${{ needs.publish-images.image-tag }} + environment: ${{ inputs.environment }} + apply: ${{ inputs.apply }} + + update-aggregator-duchy: + uses: ./.github/workflows/configure-duchy.yml + needs: publish-images + with: + duchy-name: aggregator + image-tag: ${{ needs.publish-images.image-tag }} + environment: ${{ inputs.environment }} + apply: ${{ inputs.apply }} + + update-worker1-duchy: + uses: ./.github/workflows/configure-duchy.yml + needs: publish-images + with: + duchy-name: worker1 + image-tag: ${{ needs.publish-images.image-tag }} + environment: ${{ inputs.environment }} + apply: ${{ inputs.apply }} + + update-worker2-duchy: + uses: ./.github/workflows/configure-duchy.yml + needs: publish-images + with: + duchy-name: worker2 + image-tag: ${{ needs.publish-images.image-tag }} + environment: ${{ inputs.environment }} + apply: ${{ inputs.apply }} + + # TODO(@SanjayVas): Run correctness test.