From 7e9f239dafc0f35f53e76a119275465249eb5ed8 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 19 Aug 2024 11:47:02 -0700 Subject: [PATCH] testing hubploy --- .github/workflows/deploy-to-staging.yaml | 55 +++++++++++++++++------- deployments/logodev/hubploy.yaml | 2 +- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy-to-staging.yaml b/.github/workflows/deploy-to-staging.yaml index 5bbe82a64..34a616f9d 100644 --- a/.github/workflows/deploy-to-staging.yaml +++ b/.github/workflows/deploy-to-staging.yaml @@ -16,44 +16,69 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - name: Check out the image repo uses: actions/checkout@v4 with: fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - name: print out labels just for testing - run: echo "${{ steps.pr-labels.outputs.labels }}" + - name: Pull out any hubs that need deploying from the labels on the merge commit to staging + run: | + echo "PR labels: ${{ steps.pr-labels.outputs.labels }}" + HUBS=() + for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do + if [[ "$label" == hub-* ]]; then + label=$(echo $label | awk -F'-' '{print $2}') + HUBS+="$label" + echo "DEPLOY=1" >> $GITHUB_ENV + fi + done + echo "Hubs to deploy: $HUBS" + echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV + + - name: Setup python + if: ${{ env.DEPLOY }} + uses: actions/setup-python@v5 + with: + python-version: '3.11' - name: Install dependencies + if: ${{ env.DEPLOY }} run: | python -m pip install --upgrade pip pip install -r requirements.txt pip install --force-reinstall git+https://github.com/shaneknapp/hubploy.git@major-refactor - hubploy --help - hubploy deploy --help - name: Auth to gcloud + if: ${{ env.DEPLOY }} uses: google-github-actions/auth@v2 with: credentials_json: ${{ secrets.GKE_KEY }} project_id: ${{ secrets.GCP_PROJECT_ID }} - name: Install Google Cloud SDK + if: ${{ env.DEPLOY }} uses: google-github-actions/setup-gcloud@v2 - - name: gcloud info - run: gcloud info - - name: Install SOPS + if: ${{ env.DEPLOY }} run: | mkdir -p ${HOME}/repo/bin curl -sSL https://github.com/mozilla/sops/releases/download/v3.7.0/sops-v3.7.0.linux -o ${HOME}/repo/bin/sops chmod 755 ${HOME}/repo/bin/sops + echo "${HOME}/repo/bin" >> $GITHUB_PATH + + - name: Install Helm + if: ${{ env.DEPLOY }} + run: | + curl -L https://get.helm.sh/helm-v3.13.3-linux-amd64.tar.gz | tar -xzf - + mv linux-amd64/helm /usr/local/bin + helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/ + helm repo update + + - name: Deploy hubs to staging + if: ${{ env.DEPLOY }} + run: | + for hub in $DEPLOY_HUBS[@]; do + echo "Deploying $hub to staging" + hubploy --verbose deploy $hub hub staging + done diff --git a/deployments/logodev/hubploy.yaml b/deployments/logodev/hubploy.yaml index fd2b36d2a..f6a83f0fd 100644 --- a/deployments/logodev/hubploy.yaml +++ b/deployments/logodev/hubploy.yaml @@ -1,7 +1,7 @@ images: images: # temporary update - - name: us-central1-docker.pkg.dev/ucb-datahub-2018/user-images/logodev-user-image:829f9eaececd + - name: us-central1-docker.pkg.dev/ucb-datahub-2018/user-images/logodev-user-image:a9443779a3a9 cluster: provider: gcloud