From 78f48db7f94f516d83c249ac18714b558f75c13f Mon Sep 17 00:00:00 2001 From: Mike Casale <46603283+mikewcasale@users.noreply.github.com> Date: Mon, 31 Jul 2023 13:12:34 -0700 Subject: [PATCH] Adding to exiting workflow instead of stand-alone --- .../workflows/release-and-pypi-publish.yml | 25 ++++++++++++++- .github/workflows/restart-jobs.yml | 32 ------------------- 2 files changed, 24 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/restart-jobs.yml diff --git a/.github/workflows/release-and-pypi-publish.yml b/.github/workflows/release-and-pypi-publish.yml index 5823ae936..d1563b587 100644 --- a/.github/workflows/release-and-pypi-publish.yml +++ b/.github/workflows/release-and-pypi-publish.yml @@ -22,7 +22,7 @@ # ################################################################################################################ -name: Bump Version, Generate Changelog, Create Release, and Publish +name: Bump Version, Generate Changelog, Create Release, Publish, and Restart Jobs on: push: @@ -178,4 +178,27 @@ jobs: password: ${{ secrets.FASTLANE_PYPI_API_TOKEN }} repository-url: https://upload.pypi.org/legacy/ + restart_jobs: + runs-on: ubuntu-latest + needs: combined_job + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Restart Databricks Jobs + run: | + echo "Getting list of jobs..." + JOB_LIST=$(curl -X GET -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/list") + echo "Jobs: $JOB_LIST" + + for JOB in $(echo "${JOB_LIST}" | jq -r '.jobs[].job_id'); do + JOB_INFO=$(curl -X GET -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/get?job_id=$JOB") + CLUSTER_NAME=$(echo "$JOB_INFO" | jq -r '.settings.new_cluster.cluster_name') + + if [ "$CLUSTER_NAME" = "Fastlane (v3)" ]; then + echo "Restarting job $JOB on cluster $CLUSTER_NAME..." + RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" -d "{\"job_id\": $JOB}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/run-now") + echo "Response: $RESPONSE" + fi + done + diff --git a/.github/workflows/restart-jobs.yml b/.github/workflows/restart-jobs.yml deleted file mode 100644 index 49a2c51e8..000000000 --- a/.github/workflows/restart-jobs.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Restart Databricks Jobs - -on: - workflow_run: - workflows: ["Bump Version, Generate Changelog, Create Release, and Publish"] - types: - - completed - -jobs: - restart_jobs: - runs-on: ubuntu-latest - needs: combined_job - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Restart Databricks Jobs - run: | - echo "Getting list of jobs..." - JOB_LIST=$(curl -X GET -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/list") - echo "Jobs: $JOB_LIST" - - for JOB in $(echo "${JOB_LIST}" | jq -r '.jobs[].job_id'); do - JOB_INFO=$(curl -X GET -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/get?job_id=$JOB") - CLUSTER_NAME=$(echo "$JOB_INFO" | jq -r '.settings.new_cluster.cluster_name') - - if [ "$CLUSTER_NAME" = "Fastlane (v3)" ]; then - echo "Restarting job $JOB on cluster $CLUSTER_NAME..." - RESPONSE=$(curl -X POST -H "Authorization: Bearer ${{ secrets.SERVER_TOKEN }}" -d "{\"job_id\": $JOB}" "https://${{ secrets.SERVER_DOMAIN }}/api/2.0/jobs/run-now") - echo "Response: $RESPONSE" - fi - done