CP-11565 - Update webhook secret to load for new accounts

pull/608/head
Bernardo Anderson 1 month ago
parent 48d4d25eb3
commit 4f08403c62

@ -57,6 +57,20 @@ class Account < ApplicationRecord
validates :external_account_id, uniqueness: true, allow_nil: true
after_create :create_careerplug_webhook
private
def create_careerplug_webhook
return unless ENV['CAREERPLUG_WEBHOOK_SECRET'].present?
webhook_urls.create!(
url: 'https://www.careerplug.com/api/docuseal/events',
events: %w[form.viewed form.started form.completed form.declined],
secret: { 'X-CareerPlug-Secret' => ENV.fetch('CAREERPLUG_WEBHOOK_SECRET') }
)
end
scope :active, -> { where(archived_at: nil) }
def self.find_or_create_by_external_id(external_id, name, attributes = {})

@ -170,6 +170,7 @@ fetch_env_variables() {
export SECURED_STORAGE_BUCKET=$(echo "$SECRET_JSON" | jq -r '.secured_storage_bucket')
export SECURED_STORAGE_REGION=$(echo "$SECRET_JSON" | jq -r '.secured_storage_region')
export ENCRYPTION_SECRET=$(echo "$SECRET_JSON" | jq -r '.ENCRYPTION_SECRET // empty')
export CAREERPLUG_WEBHOOK_SECRET=$(echo "$SECRET_JSON" | jq -r '.CAREERPLUG_WEBHOOK_SECRET // empty')
# Validate that we got the values
if [ "$DB_HOST" = "null" ] || [ "$REDIS_URL" = "null" ] || [ "$S3_ATTACHMENTS_BUCKET" = "null" ] || [ -z "$DB_HOST" ] || [ -z "$REDIS_URL" ] || [ -z "$S3_ATTACHMENTS_BUCKET" ]; then
@ -234,6 +235,12 @@ fetch_env_variables() {
echo "✓ ENCRYPTION_SECRET written to .env.production"
fi
# Add CareerPlug webhook secret if it exists
if [ -n "$CAREERPLUG_WEBHOOK_SECRET" ]; then
echo "CAREERPLUG_WEBHOOK_SECRET=$CAREERPLUG_WEBHOOK_SECRET" >> ./.env.production
echo "✓ CAREERPLUG_WEBHOOK_SECRET written to .env.production"
fi
echo "✓ Environment variables successfully retrieved and written to .env.production"
}

@ -174,6 +174,7 @@ fetch_env_variables() {
export SECURED_STORAGE_BUCKET=$(echo "$SECRET_JSON" | jq -r '.secured_storage_bucket')
export SECURED_STORAGE_REGION=$(echo "$SECRET_JSON" | jq -r '.secured_storage_region')
export ENCRYPTION_SECRET=$(echo "$SECRET_JSON" | jq -r '.ENCRYPTION_SECRET // empty')
export CAREERPLUG_WEBHOOK_SECRET=$(echo "$SECRET_JSON" | jq -r '.CAREERPLUG_WEBHOOK_SECRET // empty')
# Validate that we got the values
@ -239,6 +240,12 @@ fetch_env_variables() {
echo "✓ ENCRYPTION_SECRET written to .env.staging"
fi
# Add CareerPlug webhook secret if it exists
if [ -n "$CAREERPLUG_WEBHOOK_SECRET" ]; then
echo "CAREERPLUG_WEBHOOK_SECRET=$CAREERPLUG_WEBHOOK_SECRET" >> ./.env.staging
echo "✓ CAREERPLUG_WEBHOOK_SECRET written to .env.staging"
fi
echo "✓ Environment variables successfully retrieved and written to .env.staging"
}

Loading…
Cancel
Save