From 908314284eca82b52c61044610a27ac94a1fff56 Mon Sep 17 00:00:00 2001 From: Trent Clarke Date: Sat, 25 Jun 2022 08:17:11 +1000 Subject: [PATCH] Docs image CI/CD script (#76) Adds a build script that will construct and publish the `docs` image to `quay.io`. This build script will be triggered by Google Cloud Build on a push to `main`. The upshot of this script is that the image used by Teleoprt CI to run its doctests will be automatically updated every time a PR is merged in this repository. See-Also: gravitational/teleport#13457 --- .cloudbuild/image.yaml | 18 ++++++++++++++++++ .cloudbuild/publish-image.sh | 7 +++++++ 2 files changed, 25 insertions(+) create mode 100644 .cloudbuild/image.yaml create mode 100755 .cloudbuild/publish-image.sh diff --git a/.cloudbuild/image.yaml b/.cloudbuild/image.yaml new file mode 100644 index 0000000000..61e6ab99ff --- /dev/null +++ b/.cloudbuild/image.yaml @@ -0,0 +1,18 @@ +steps: + - name: 'gcr.io/cloud-builders/docker' + env: + - DOCKER_BUILDKIT=1 + - DOCKER_REGISTRY=quay.io + - DOCKER_REPOSITORY=gravitational/docs + - DOCKER_TAG=latest + secretEnv: + - QUAYIO_DOCKER_USERNAME + - QUAYIO_DOCKER_PASSWORD + script: .cloudbuild/publish-image.sh +availableSecrets: + secretManager: + - versionName: projects/771512790633/secrets/ci_docs-quay_io_username/versions/1 + env: QUAYIO_DOCKER_USERNAME + - versionName: projects/771512790633/secrets/ci_docs_quay_io_password/versions/1 + env: QUAYIO_DOCKER_PASSWORD + diff --git a/.cloudbuild/publish-image.sh b/.cloudbuild/publish-image.sh new file mode 100755 index 0000000000..c3e1280fd6 --- /dev/null +++ b/.cloudbuild/publish-image.sh @@ -0,0 +1,7 @@ +#! /bin/env bash +set -e +IMAGE_NAME=$DOCKER_REGISTRY/$DOCKER_REPOSITORY:$DOCKER_TAG +echo Building $IMAGE_NAME +DOCKER_BUILDKIT=1 docker build -t $IMAGE_NAME . +echo $QUAYIO_DOCKER_PASSWORD | docker login -u $QUAYIO_DOCKER_USERNAME --password-stdin $DOCKER_REGISTRY +docker push $IMAGE_NAME