Skip to content

Commit

Permalink
Add workflow for updating CMMS deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas committed May 4, 2023
1 parent 7e1aecd commit d5604ef
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 9 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/configure-duchy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ 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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand All @@ -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"

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/export-duchy-cert-id.sh
Original file line number Diff line number Diff line change
@@ -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"
63 changes: 63 additions & 0 deletions .github/workflows/update-cmms.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 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

# TODO(@SanjayVas): Specify workflow_dispatch and release triggers instead.
on:
pull_request:
types: [ opened, synchronize, edited ]

# TODO(@SanjayVas): Read environment/apply from inputs.

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: dev
apply: false

update-aggregator-duchy:
uses: ./.github/workflows/configure-duchy.yml
needs: publish-images
with:
duchy-name: aggregator
image-tag: ${{ needs.publish-images.image-tag }}
environment: dev
apply: false

update-worker1-duchy:
uses: ./.github/workflows/configure-duchy.yml
needs: publish-images
with:
duchy-name: worker1
image-tag: ${{ needs.publish-images.image-tag }}
environment: dev
apply: false

update-worker2-duchy:
uses: ./.github/workflows/configure-duchy.yml
needs: publish-images
with:
duchy-name: worker2
image-tag: ${{ needs.publish-images.image-tag }}
environment: dev
apply: false

0 comments on commit d5604ef

Please sign in to comment.