From 3b87bc02abcd3fa65026e5c5a5f7445a4db3a453 Mon Sep 17 00:00:00 2001 From: Pudong Zheng Date: Wed, 24 Apr 2024 19:46:43 +0000 Subject: [PATCH] use previewctl:install --- .github/actions/delete-preview/entrypoint.sh | 3 ++- .github/actions/delete-preview/metadata.yml | 3 --- .github/actions/deploy-gitpod/entrypoint.sh | 3 ++- .github/actions/deploy-gitpod/metadata.yml | 3 --- .../deploy-monitoring-satellite/entrypoint.sh | 3 ++- .../deploy-monitoring-satellite/metadata.yml | 3 --- .github/actions/preview-create/entrypoint.sh | 3 ++- .github/actions/preview-create/metadata.yml | 6 ----- .github/workflows/build.yml | 6 +---- dev/preview/previewctl/BUILD.yaml | 27 ------------------- .../workflow/preview/configure-workspace.sh | 2 +- 11 files changed, 10 insertions(+), 52 deletions(-) diff --git a/.github/actions/delete-preview/entrypoint.sh b/.github/actions/delete-preview/entrypoint.sh index 7742cc8604141e..c08e808f9e510b 100755 --- a/.github/actions/delete-preview/entrypoint.sh +++ b/.github/actions/delete-preview/entrypoint.sh @@ -9,7 +9,8 @@ export PATH="$PATH:$HOME/bin" mkdir $HOME/bin -leeway run dev/preview/previewctl:download +gcloud auth login --cred-file="$GOOGLE_APPLICATION_CREDENTIALS" --activate --quiet +leeway run dev/preview/previewctl:install export TF_INPUT=0 export TF_IN_AUTOMATION=true diff --git a/.github/actions/delete-preview/metadata.yml b/.github/actions/delete-preview/metadata.yml index 0a1cdf4eff8f25..818dc5f7650173 100644 --- a/.github/actions/delete-preview/metadata.yml +++ b/.github/actions/delete-preview/metadata.yml @@ -4,9 +4,6 @@ inputs: name: description: "The name of the preview environment" required: true - previewctl_hash: - description: "The Leeway hash of the dev/preview/previewctl:docker package to be used when downloading previewclt" - required: false runs: using: "docker" image: "Dockerfile" diff --git a/.github/actions/deploy-gitpod/entrypoint.sh b/.github/actions/deploy-gitpod/entrypoint.sh index 9b48285e6193a7..5aa3c6b380f4f8 100755 --- a/.github/actions/deploy-gitpod/entrypoint.sh +++ b/.github/actions/deploy-gitpod/entrypoint.sh @@ -19,7 +19,8 @@ chmod +x $HOME/bin/installer echo "Download versions.yaml" oci-tool fetch file -o /tmp/versions.yaml --platform=linux-amd64 "${IMAGE_REPO_BASE}/versions:${VERSION}" versions.yaml -leeway run dev/preview/previewctl:download +gcloud auth login --cred-file="$GOOGLE_APPLICATION_CREDENTIALS" --activate --quiet +leeway run dev/preview/previewctl:install PREVIEW_NAME="$(previewctl get-name --branch "${INPUT_NAME}")" export PREVIEW_NAME diff --git a/.github/actions/deploy-gitpod/metadata.yml b/.github/actions/deploy-gitpod/metadata.yml index ad842cebd7ef04..689c775c428b65 100644 --- a/.github/actions/deploy-gitpod/metadata.yml +++ b/.github/actions/deploy-gitpod/metadata.yml @@ -10,9 +10,6 @@ inputs: version: description: "The version of Gitpod to install" required: true - previewctl_hash: - description: "The Leeway hash of the dev/preview/previewctl:docker package to be used when downloading previewclt" - required: false with_dedicated_emu: description: "Dedicated Config" required: false diff --git a/.github/actions/deploy-monitoring-satellite/entrypoint.sh b/.github/actions/deploy-monitoring-satellite/entrypoint.sh index 36190e91ad037a..e822edb3fedb0f 100755 --- a/.github/actions/deploy-monitoring-satellite/entrypoint.sh +++ b/.github/actions/deploy-monitoring-satellite/entrypoint.sh @@ -9,7 +9,8 @@ export PATH="$PATH:$HOME/bin" mkdir $HOME/bin -leeway run dev/preview/previewctl:download +gcloud auth login --cred-file="$GOOGLE_APPLICATION_CREDENTIALS" --activate --quiet +leeway run dev/preview/previewctl:install echo "previewctl install-context" previewctl install-context --log-level debug --timeout 10m diff --git a/.github/actions/deploy-monitoring-satellite/metadata.yml b/.github/actions/deploy-monitoring-satellite/metadata.yml index ab8b2977503f08..e7eb37cc6bb00c 100644 --- a/.github/actions/deploy-monitoring-satellite/metadata.yml +++ b/.github/actions/deploy-monitoring-satellite/metadata.yml @@ -4,9 +4,6 @@ inputs: sa_key: description: "The service account key to use when authenticating with GCP" required: true - previewctl_hash: - description: "The Leeway hash of the dev/preview/previewctl:docker package to be used when downloading previewclt" - required: false runs: using: "docker" image: "Dockerfile" diff --git a/.github/actions/preview-create/entrypoint.sh b/.github/actions/preview-create/entrypoint.sh index 918cd8cb216f69..f5a9709711e9d5 100755 --- a/.github/actions/preview-create/entrypoint.sh +++ b/.github/actions/preview-create/entrypoint.sh @@ -9,7 +9,8 @@ export PATH="$PATH:$HOME/bin" mkdir $HOME/bin -leeway run dev/preview/previewctl:download +gcloud auth login --cred-file="$GOOGLE_APPLICATION_CREDENTIALS" --activate --quiet +leeway run dev/preview/previewctl:install TF_VAR_preview_name="$(previewctl get-name --branch "${INPUT_NAME}")" export TF_VAR_preview_name diff --git a/.github/actions/preview-create/metadata.yml b/.github/actions/preview-create/metadata.yml index e49f1ab9d1b5bf..134bf610fcc708 100644 --- a/.github/actions/preview-create/metadata.yml +++ b/.github/actions/preview-create/metadata.yml @@ -15,12 +15,6 @@ inputs: description: "Whether to use preemptible VMs for the env" required: true default: true - sa_key: - description: "The service account key to use when authenticating with GCP" - required: true - previewctl_hash: - description: "The Leeway hash of the dev/preview/previewctl:docker package to be used when downloading previewclt" - required: false recreate_vm: description: "Whether to recreate the VM" required: false diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 65d15f7bcccfbe..55a4d496016f43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,8 +104,6 @@ jobs: runs-on: ${{ needs.create-runner.outputs.label }} container: image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:pd-test-new-preview-gha.24525 - outputs: - previewctl_hash: ${{ steps.build.outputs.previewctl_hash }} steps: - uses: actions/checkout@v4 - name: Setup Environment @@ -122,9 +120,7 @@ jobs: run: | version="${{needs.configuration.outputs.version}}" imageRepoBase="${{needs.configuration.outputs.image_repo_base}}/build" - leeway build dev/preview/previewctl:docker -Dversion=$version -DimageRepoBase=$imageRepoBase - echo "previewctl_hash=$(leeway describe dev/preview/previewctl:docker -Dversion=$version -DimageRepoBase=$imageRepoBase -t '{{ .Metadata.Version }}')" >> $GITHUB_OUTPUT - + leeway build dev/preview/previewctl:docker --cache remote -Dversion=$version -DimageRepoBase=$imageRepoBase infrastructure: needs: [ configuration, build-previewctl, create-runner ] if: | diff --git a/dev/preview/previewctl/BUILD.yaml b/dev/preview/previewctl/BUILD.yaml index dceadc10d14d47..1862e86a36ba66 100644 --- a/dev/preview/previewctl/BUILD.yaml +++ b/dev/preview/previewctl/BUILD.yaml @@ -40,30 +40,3 @@ scripts: description: Build and install previewctl into the current environment script: leeway build dev/preview/previewctl:install -Dno-cache=$RANDOM --dont-test --cache=remote-pull - - name: download - description: - script: | - IMAGE_REPO_BASE=eu.gcr.io/gitpod-core-dev/build - - if [[ -z "$INPUT_PREVIEWCTL_HASH" ]]; then - # If a specific hash isn't provided we'll use the latest image of main - PREVIEWCTL_VERSION=$(\ - gcloud container images list-tags $IMAGE_REPO_BASE/previewctl \ - --filter="tags:main-gha.*" \ - --limit=1 \ - --format=json \ - | jq --raw-output '.[0].tags[0]' \ - ) - PREVIEWCTL_IMAGE="$IMAGE_REPO_BASE/previewctl:$PREVIEWCTL_VERSION" - else - if [[ -n "$INPUT_IMAGE_REPO_BASE" ]]; then - IMAGE_REPO_BASE=$INPUT_IMAGE_REPO_BASE - fi - PREVIEWCTL_IMAGE="$IMAGE_REPO_BASE/previewctl:hash-$INPUT_PREVIEWCTL_HASH" - fi - - echo $PREVIEWCTL_IMAGE - - echo "Downloading previewctl for $PREVIEWCTL_IMAGE" - oci-tool fetch file -o $HOME/bin/previewctl --platform=linux-amd64 "$PREVIEWCTL_IMAGE" app/previewctl - chmod +x $HOME/bin/previewctl diff --git a/dev/preview/workflow/preview/configure-workspace.sh b/dev/preview/workflow/preview/configure-workspace.sh index 5c1731c3317715..73766460008f59 100755 --- a/dev/preview/workflow/preview/configure-workspace.sh +++ b/dev/preview/workflow/preview/configure-workspace.sh @@ -22,7 +22,7 @@ if [ ! -f "${PREVIEW_ENV_DEV_SA_KEY_PATH}" ]; then echo "${PREVIEW_ENV_DEV_CRED}" >"${PREVIEW_ENV_DEV_SA_KEY_PATH}" fi -gcloud auth login --cred-file "${PREVIEW_ENV_DEV_SA_KEY_PATH}" +gcloud auth login --cred-file "${PREVIEW_ENV_DEV_SA_KEY_PATH}" --activate --quiet if [[ -n "${INSTALL_CONTEXT:-}" ]]; then log_info "Starting watch-loop to configure access to your preview environment"