From 6a957b04a267b7d2f1adbe1ada480927947a0360 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 19 Aug 2024 14:46:27 -0700 Subject: [PATCH 1/8] clone staging deploy workflow and s/staging/prod/g --- .../workflows/deploy-to-prod.yaml.disabled | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/deploy-to-prod.yaml.disabled diff --git a/.github/workflows/deploy-to-prod.yaml.disabled b/.github/workflows/deploy-to-prod.yaml.disabled new file mode 100644 index 000000000..0cd1a2ba0 --- /dev/null +++ b/.github/workflows/deploy-to-prod.yaml.disabled @@ -0,0 +1,94 @@ +name: Deploy images to prod hubs +# use echo ${VAR##*: } to get the value of a variable that is a string with a colon in it +on: + workflow_dispatch: + push: + branches: + - prod + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Get PR labels + id: pr-labels + uses: irby/get-labels-on-push@v1.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check out the image repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + + - name: Pull out any hubs that need deploying from the labels on the merge commit to prod + 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 + + - 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 + with: + install_components: 'gke-gcloud-auth-plugin' + + - name: Install SOPS + if: ${{ env.DEPLOY }} + run: | + mkdir -p ${HOME}/bin + curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops + chmod 755 ${HOME}/bin/sops + echo "${HOME}/bin" >> $GITHUB_PATH + + - name: Store SOPS secret in a file + if: ${{ env.DEPLOY }} + run: | + cat << EOF > ${HOME}/sops.key + ${{ secrets.SOPS_KEY }} + EOF + echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV + + - 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 prod + if: ${{ env.DEPLOY }} + run: | + for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do + echo "Deploying $hub to prod" + hubploy --verbose deploy $hub hub prod + done From bc00743eb67c1b0dfb94297ad6f9c9bdf5d35131 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 11:19:49 -0700 Subject: [PATCH 2/8] combine staging/prod deploy to one workflow, skip if we need to deploy all hubs --- .github/workflows/deploy-hubs.yaml | 202 ++++++++++++++++++ .../deploy-jupyterhub-base-images.yaml | 41 ++-- .../workflows/deploy-to-prod.yaml.disabled | 94 -------- .../workflows/deploy-to-staging.yaml.disabled | 94 -------- 4 files changed, 225 insertions(+), 206 deletions(-) create mode 100644 .github/workflows/deploy-hubs.yaml delete mode 100644 .github/workflows/deploy-to-prod.yaml.disabled delete mode 100644 .github/workflows/deploy-to-staging.yaml.disabled diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml new file mode 100644 index 000000000..77d1fe468 --- /dev/null +++ b/.github/workflows/deploy-hubs.yaml @@ -0,0 +1,202 @@ +# this workflow re-deploys SPECIFIC hubs to staging or prod if the single-user +# server image or config has changed based on the PR labels "hub: ". +# +# however, this workflow will be not run if the PR labels of "hub-images" or +# "jupyterhub-deployment" are present, as these labels will trigger the +# "deploy-jupyterhub-base-images.yaml" workflow which re-deploys every hub. +# +name: Deploy staging and prod hubs +on: + workflow_dispatch: + push: + branches: + - staging + - prod + +jobs: + deploy-hubs-to-staging: + if: github.event_name == 'push' && github.ref == 'refs/heads/staging' + runs-on: ubuntu-latest + steps: + - name: Get PR labels + id: pr-labels + uses: irby/get-labels-on-push@v1.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - 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 + # If the PR labels "hub-images" or "jupyterhub-deployment" are present, this + # means the base hub image has changed, and all hubs (staging or prod) need to + # be redeployed. This workflow will not run in that case. + if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then + echo "Base hub image has changed, not deploying individual hubs to staging" + echo "DEPLOY=0" >> $GITHUB_ENV + fi + echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV + + - name: Check out the image repo + if: ${{ env.DEPLOY }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + + - 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 + + - 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 + with: + install_components: 'gke-gcloud-auth-plugin' + + - name: Install SOPS + if: ${{ env.DEPLOY }} + run: | + mkdir -p ${HOME}/bin + curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops + chmod 755 ${HOME}/bin/sops + echo "${HOME}/bin" >> $GITHUB_PATH + + - name: Store SOPS secret in a file + if: ${{ env.DEPLOY }} + run: | + cat << EOF > ${HOME}/sops.key + ${{ secrets.SOPS_KEY }} + EOF + echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV + + - 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 $(echo -e "${{ env.DEPLOY_HUBS }}"); do + echo "Deploying $hub to staging" + echo "hubploy --verbose deploy $hub hub staging" + done + + deploy-hubs-to-prod: + if: github.event_name == 'push' && github.ref == 'refs/heads/prod' + runs-on: ubuntu-latest + steps: + - name: Get PR labels + id: pr-labels + uses: irby/get-labels-on-push@v1.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check out the image repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + + - name: Pull out any hubs that need deploying from the labels on the merge commit to prod + 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 + # If the PR labels "hub-images" or "jupyterhub-deployment" are present, this + # means the base hub image has changed, and all hubs (staging or prod) need to + # be redeployed. This workflow will not run in that case. + if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then + echo "Base hub image has changed, not deploying individual hubs to prod" + echo "DEPLOY=0" >> $GITHUB_ENV + fi + 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 + + - 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 + with: + install_components: 'gke-gcloud-auth-plugin' + + - name: Install SOPS + if: ${{ env.DEPLOY }} + run: | + mkdir -p ${HOME}/bin + curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops + chmod 755 ${HOME}/bin/sops + echo "${HOME}/bin" >> $GITHUB_PATH + + - name: Store SOPS secret in a file + if: ${{ env.DEPLOY }} + run: | + cat << EOF > ${HOME}/sops.key + ${{ secrets.SOPS_KEY }} + EOF + echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV + + - 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 prod + if: ${{ env.DEPLOY }} + run: | + for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do + echo "Deploying $hub to prod" + echo "hubploy --verbose deploy $hub hub prod" + done diff --git a/.github/workflows/deploy-jupyterhub-base-images.yaml b/.github/workflows/deploy-jupyterhub-base-images.yaml index ff84d0845..5323dc8ff 100644 --- a/.github/workflows/deploy-jupyterhub-base-images.yaml +++ b/.github/workflows/deploy-jupyterhub-base-images.yaml @@ -1,4 +1,8 @@ -name: Deploy base hub images to staging +# if the PR labels "hub-images" or "jupyterhub-deployment" are present, this +# means the base hub image has changed, and all hubs (staging or prod) need to +# be redeployed. +# +name: Deploy base hub images to all hubs in staging and prod on: workflow_dispatch: push: @@ -17,11 +21,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check out the image repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - 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 }}" @@ -30,12 +29,18 @@ jobs: echo "DEPLOY=1" >> $GITHUB_ENV fi done - if [[ -n "${DEPLOY}" ]]; then - echo "Deploying base hub images to all deployments" + if [[ -n "${{ env.DEPLOY }}" ]]; then + echo "Deploying base hub images to all deployments on staging" else - echo "No hub images to deploy" + echo "No hub images to deploy to staging" fi + - name: Check out the image repo + if: ${{ env.DEPLOY }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + - name: Setup python if: ${{ env.DEPLOY }} uses: actions/setup-python@v5 @@ -89,7 +94,7 @@ jobs: - name: Deploy base hub images to staging if: ${{ env.DEPLOY }} run: | - ignored_directories=("template") # these are directories that we never want to deploy to + ignored_directories=("template") # these are directories that we never want to deploy while read deployment; do for ignored in "${ignored_directories[@]}"; do if [[ "${deployment}" == "${ignored}" ]]; then @@ -110,11 +115,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Check out the image repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - name: Pull out any hubs that need deploying from the labels on the merge commit to prod run: | echo "PR labels: ${{ steps.pr-labels.outputs.labels }}" @@ -123,12 +123,17 @@ jobs: echo "DEPLOY=1" >> $GITHUB_ENV fi done - if [[ -n "${DEPLOY}" ]]; then - echo "Deploying base hub images to all deployments" + if [[ -n "${{ env.DEPLOY }}" ]]; then + echo "Deploying base hub images to all deployments on prod" else echo "No hub images to deploy" fi + - name: Check out the image repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. + - name: Setup python if: ${{ env.DEPLOY }} uses: actions/setup-python@v5 @@ -182,7 +187,7 @@ jobs: - name: Deploy base hub images to prod if: ${{ env.DEPLOY }} run: | - ignored_directories=("template") # these are directories that we never want to deploy to + ignored_directories=("template") # these are directories that we never want to deploy while read deployment; do for ignored in "${ignored_directories[@]}"; do if [[ "${deployment}" == "${ignored}" ]]; then diff --git a/.github/workflows/deploy-to-prod.yaml.disabled b/.github/workflows/deploy-to-prod.yaml.disabled deleted file mode 100644 index 0cd1a2ba0..000000000 --- a/.github/workflows/deploy-to-prod.yaml.disabled +++ /dev/null @@ -1,94 +0,0 @@ -name: Deploy images to prod hubs -# use echo ${VAR##*: } to get the value of a variable that is a string with a colon in it -on: - workflow_dispatch: - push: - branches: - - prod - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Get PR labels - id: pr-labels - uses: irby/get-labels-on-push@v1.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check out the image repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - name: Pull out any hubs that need deploying from the labels on the merge commit to prod - 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 - - - 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 - with: - install_components: 'gke-gcloud-auth-plugin' - - - name: Install SOPS - if: ${{ env.DEPLOY }} - run: | - mkdir -p ${HOME}/bin - curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops - chmod 755 ${HOME}/bin/sops - echo "${HOME}/bin" >> $GITHUB_PATH - - - name: Store SOPS secret in a file - if: ${{ env.DEPLOY }} - run: | - cat << EOF > ${HOME}/sops.key - ${{ secrets.SOPS_KEY }} - EOF - echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV - - - 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 prod - if: ${{ env.DEPLOY }} - run: | - for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do - echo "Deploying $hub to prod" - hubploy --verbose deploy $hub hub prod - done diff --git a/.github/workflows/deploy-to-staging.yaml.disabled b/.github/workflows/deploy-to-staging.yaml.disabled deleted file mode 100644 index c72f4db5b..000000000 --- a/.github/workflows/deploy-to-staging.yaml.disabled +++ /dev/null @@ -1,94 +0,0 @@ -name: Deploy images to staging hubs -# use echo ${VAR##*: } to get the value of a variable that is a string with a colon in it -on: - workflow_dispatch: - push: - branches: - - staging - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Get PR labels - id: pr-labels - uses: irby/get-labels-on-push@v1.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Check out the image repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 # OR "2" -> To retrieve the preceding commit. - - - 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 - - - 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 - with: - install_components: 'gke-gcloud-auth-plugin' - - - name: Install SOPS - if: ${{ env.DEPLOY }} - run: | - mkdir -p ${HOME}/bin - curl -sSL https://github.com/getsops/sops/releases/download/v3.9.0/sops-v3.9.0.linux.amd64 -o ${HOME}/bin/sops - chmod 755 ${HOME}/bin/sops - echo "${HOME}/bin" >> $GITHUB_PATH - - - name: Store SOPS secret in a file - if: ${{ env.DEPLOY }} - run: | - cat << EOF > ${HOME}/sops.key - ${{ secrets.SOPS_KEY }} - EOF - echo "GOOGLE_APPLICATION_CREDENTIALS=${HOME}/sops.key" >> $GITHUB_ENV - - - 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 $(echo -e "${{ env.DEPLOY_HUBS }}"); do - echo "Deploying $hub to staging" - hubploy --verbose deploy $hub hub staging - done From c563e20457bb96f7a04520751ba7ad72431bc780 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 11:25:46 -0700 Subject: [PATCH 3/8] s/triage/apply-labels --- .github/workflows/labeler.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 07b21837d..d886cd0dd 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -3,7 +3,7 @@ on: - pull_request_target jobs: - triage: + apply-labels: permissions: contents: read pull-requests: write From 69c4b09f50ec20578a48e30a9cd32c1d21364704 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 11:28:48 -0700 Subject: [PATCH 4/8] s/debug/verbose --- .github/workflows/deploy-hubs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 77d1fe468..0613d792c 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -105,7 +105,7 @@ jobs: run: | for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do echo "Deploying $hub to staging" - echo "hubploy --verbose deploy $hub hub staging" + echo "hubploy --debug deploy $hub hub staging" done deploy-hubs-to-prod: @@ -198,5 +198,5 @@ jobs: run: | for hub in $(echo -e "${{ env.DEPLOY_HUBS }}"); do echo "Deploying $hub to prod" - echo "hubploy --verbose deploy $hub hub prod" + echo "hubploy --debug deploy $hub hub prod" done From ec636c3568cc7e09dbb3e1fc96b3115c4a438512 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 11:32:16 -0700 Subject: [PATCH 5/8] more wording --- .github/workflows/deploy-jupyterhub-base-images.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-jupyterhub-base-images.yaml b/.github/workflows/deploy-jupyterhub-base-images.yaml index 5323dc8ff..18736907e 100644 --- a/.github/workflows/deploy-jupyterhub-base-images.yaml +++ b/.github/workflows/deploy-jupyterhub-base-images.yaml @@ -124,7 +124,7 @@ jobs: fi done if [[ -n "${{ env.DEPLOY }}" ]]; then - echo "Deploying base hub images to all deployments on prod" + echo "Deploying base hub images to all deployments to prod" else echo "No hub images to deploy" fi From ec0286ba906a96ece9ffdcee3c80713547edf296 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 15:16:19 -0700 Subject: [PATCH 6/8] more tweaking and better logic flow + file rename to something sane --- ...-base-images.yaml => deploy-all-hubs.yaml} | 0 .github/workflows/deploy-hubs.yaml | 40 ++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) rename .github/workflows/{deploy-jupyterhub-base-images.yaml => deploy-all-hubs.yaml} (100%) diff --git a/.github/workflows/deploy-jupyterhub-base-images.yaml b/.github/workflows/deploy-all-hubs.yaml similarity index 100% rename from .github/workflows/deploy-jupyterhub-base-images.yaml rename to .github/workflows/deploy-all-hubs.yaml diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 0613d792c..39919229b 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -28,21 +28,23 @@ jobs: 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 # If the PR labels "hub-images" or "jupyterhub-deployment" are present, this # means the base hub image has changed, and all hubs (staging or prod) need to - # be redeployed. This workflow will not run in that case. + # be redeployed. The rest of this job will not run in that case. if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then echo "Base hub image has changed, not deploying individual hubs to staging" echo "DEPLOY=0" >> $GITHUB_ENV + else + # deploy any hubs that have been labeled for deployment + 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 "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV fi - echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV - name: Check out the image repo if: ${{ env.DEPLOY }} @@ -127,21 +129,23 @@ jobs: 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 # If the PR labels "hub-images" or "jupyterhub-deployment" are present, this # means the base hub image has changed, and all hubs (staging or prod) need to - # be redeployed. This workflow will not run in that case. + # be redeployed. The rest of this job will not run in that case. if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then echo "Base hub image has changed, not deploying individual hubs to prod" echo "DEPLOY=0" >> $GITHUB_ENV + else + # deploy any hubs that have been labeled for deployment + 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 "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV fi - echo "DEPLOY_HUBS=${HUBS[@]}" >> $GITHUB_ENV - name: Setup python if: ${{ env.DEPLOY }} From ee7dd887791a076158e9d40ec8ae76fc3f04b7e3 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 15:23:48 -0700 Subject: [PATCH 7/8] for seriously --- .github/workflows/deploy-hubs.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy-hubs.yaml b/.github/workflows/deploy-hubs.yaml index 39919229b..bea73df68 100644 --- a/.github/workflows/deploy-hubs.yaml +++ b/.github/workflows/deploy-hubs.yaml @@ -33,7 +33,6 @@ jobs: # be redeployed. The rest of this job will not run in that case. if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then echo "Base hub image has changed, not deploying individual hubs to staging" - echo "DEPLOY=0" >> $GITHUB_ENV else # deploy any hubs that have been labeled for deployment for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do @@ -134,7 +133,6 @@ jobs: # be redeployed. The rest of this job will not run in that case. if [ -n $GITHUB_PR_LABEL_HUB_IMAGES ] || [ -n $GITHUB_PR_LABEL_JUPYTERHUB_DEPLOYMENT ]; then echo "Base hub image has changed, not deploying individual hubs to prod" - echo "DEPLOY=0" >> $GITHUB_ENV else # deploy any hubs that have been labeled for deployment for label in $(echo -e "${{ steps.pr-labels.outputs.labels }}"); do From b0f0cfa7f2ca543c60f32b5b67b651e6c0f23a42 Mon Sep 17 00:00:00 2001 From: shane knapp Date: Mon, 26 Aug 2024 15:44:09 -0700 Subject: [PATCH 8/8] removing some old debugging text --- .github/workflows/deploy-all-hubs.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/deploy-all-hubs.yaml b/.github/workflows/deploy-all-hubs.yaml index 18736907e..fbc149187 100644 --- a/.github/workflows/deploy-all-hubs.yaml +++ b/.github/workflows/deploy-all-hubs.yaml @@ -29,11 +29,6 @@ jobs: echo "DEPLOY=1" >> $GITHUB_ENV fi done - if [[ -n "${{ env.DEPLOY }}" ]]; then - echo "Deploying base hub images to all deployments on staging" - else - echo "No hub images to deploy to staging" - fi - name: Check out the image repo if: ${{ env.DEPLOY }} @@ -123,11 +118,6 @@ jobs: echo "DEPLOY=1" >> $GITHUB_ENV fi done - if [[ -n "${{ env.DEPLOY }}" ]]; then - echo "Deploying base hub images to all deployments to prod" - else - echo "No hub images to deploy" - fi - name: Check out the image repo uses: actions/checkout@v4