From 6c672c73e49ce6ca2d0e13bb187ef10aa69b426f Mon Sep 17 00:00:00 2001 From: Aaron Santos Date: Wed, 29 Oct 2025 10:25:28 +0800 Subject: [PATCH] Send notification to Dash on deploys --- .kamal/hooks/post-deploy | 2 ++ .kamal/secrets.beta | 3 ++- .kamal/secrets.dhh | 3 ++- .kamal/secrets.production | 3 ++- .kamal/secrets.staging | 3 ++- bin/notify_dash_of_deployment | 25 +++++++++++++++++++++++++ 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100755 bin/notify_dash_of_deployment diff --git a/.kamal/hooks/post-deploy b/.kamal/hooks/post-deploy index 9ad72e66a..871506078 100755 --- a/.kamal/hooks/post-deploy +++ b/.kamal/hooks/post-deploy @@ -3,6 +3,8 @@ MESSAGE="$KAMAL_PERFORMER deployed $KAMAL_SERVICE_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds" CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) +bin/notify_dash_of_deployment "$MESSAGE" $KAMAL_VERSION $KAMAL_PERFORMER $CURRENT_BRANCH $KAMAL_DESTINATION $KAMAL_RUNTIME + if [[ $CURRENT_BRANCH == "main" && $KAMAL_DESTINATION == "production" ]]; then gh release create $KAMAL_SERVICE_VERSION --target $KAMAL_VERSION --generate-notes 2> /dev/null || true diff --git a/.kamal/secrets.beta b/.kamal/secrets.beta index 60d911ced..9d9a33d9f 100644 --- a/.kamal/secrets.beta +++ b/.kamal/secrets.beta @@ -1,5 +1,6 @@ -SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Beta/RAILS_MASTER_KEY) +SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Beta/RAILS_MASTER_KEY) GITHUB_TOKEN=$(gh config get -h github.com oauth_token) BASECAMP_REGISTRY_PASSWORD=$(kamal secrets extract BASECAMP_REGISTRY_PASSWORD $SECRETS) +DASH_BASIC_AUTH_SECRET=$(kamal secrets extract DASH_BASIC_AUTH_SECRET $SECRETS) RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS) diff --git a/.kamal/secrets.dhh b/.kamal/secrets.dhh index 60d911ced..9d9a33d9f 100644 --- a/.kamal/secrets.dhh +++ b/.kamal/secrets.dhh @@ -1,5 +1,6 @@ -SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Beta/RAILS_MASTER_KEY) +SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Beta/RAILS_MASTER_KEY) GITHUB_TOKEN=$(gh config get -h github.com oauth_token) BASECAMP_REGISTRY_PASSWORD=$(kamal secrets extract BASECAMP_REGISTRY_PASSWORD $SECRETS) +DASH_BASIC_AUTH_SECRET=$(kamal secrets extract DASH_BASIC_AUTH_SECRET $SECRETS) RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS) diff --git a/.kamal/secrets.production b/.kamal/secrets.production index b6d71edd3..5326c7214 100644 --- a/.kamal/secrets.production +++ b/.kamal/secrets.production @@ -1,5 +1,6 @@ -SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Production/RAILS_MASTER_KEY) +SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Production/RAILS_MASTER_KEY) GITHUB_TOKEN=$(gh config get -h github.com oauth_token) BASECAMP_REGISTRY_PASSWORD=$(kamal secrets extract BASECAMP_REGISTRY_PASSWORD $SECRETS) +DASH_BASIC_AUTH_SECRET=$(kamal secrets extract DASH_BASIC_AUTH_SECRET $SECRETS) RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS) diff --git a/.kamal/secrets.staging b/.kamal/secrets.staging index f7d1a309f..46eccf3fd 100644 --- a/.kamal/secrets.staging +++ b/.kamal/secrets.staging @@ -1,5 +1,6 @@ -SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Staging/RAILS_MASTER_KEY) +SECRETS=$(kamal secrets fetch --adapter 1password --account basecamp --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Staging/RAILS_MASTER_KEY) GITHUB_TOKEN=$(gh config get -h github.com oauth_token) BASECAMP_REGISTRY_PASSWORD=$(kamal secrets extract BASECAMP_REGISTRY_PASSWORD $SECRETS) +DASH_BASIC_AUTH_SECRET=$(kamal secrets extract DASH_BASIC_AUTH_SECRET $SECRETS) RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS) diff --git a/bin/notify_dash_of_deployment b/bin/notify_dash_of_deployment new file mode 100755 index 000000000..b7c2b8418 --- /dev/null +++ b/bin/notify_dash_of_deployment @@ -0,0 +1,25 @@ +#!/bin/sh + +# Example usage: bin/notify_dash_of_deployment $MESSAGE $KAMAL_VERSION $KAMAL_PERFORMER $CURRENT_BRANCH $KAMAL_DESTINATION $KAMAL_RUNTIME + +if [ -n "$DASH_BASIC_AUTH_SECRET" ]; then + jq -n -c --arg message "${1}" \ + --arg commit "${2}" \ + --arg author "${3}" \ + --arg branch "${4}" \ + --arg env "${5}" \ + --arg duration "${6}" \ + '{ + "application":"boxcar", + "rails_env": $env, + "branch": $branch, + "deployer": $author, + "message": $message, + "rev": $commit, + "duration": $duration + }' | + curl --user "$DASH_BASIC_AUTH_SECRET" -H "Content-Type: application/json" --data-binary @- \ + https://dash.37signals.com/deploy +else + echo "WARNING: Dash deploy notification not sent." +fi