Skip to content

Commit

Permalink
Merge pull request #50 from bancorprotocol/46-add-new-github-action-f…
Browse files Browse the repository at this point in the history
…or-automating-production-job-restart-upon-new-version-update

Adding to exiting workflow instead of stand-alone
  • Loading branch information
mikewcasale authored Aug 2, 2023
2 parents f0ebbb0 + 9a5ca7f commit bee9138
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 33 deletions.
25 changes: 24 additions & 1 deletion .github/workflows/release-and-pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
32 changes: 0 additions & 32 deletions .github/workflows/restart-jobs.yml

This file was deleted.

0 comments on commit bee9138

Please sign in to comment.