#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/00_dokku-standard/exec-app-json-scripts"

exec_app_json_scripts() {
  declare desc="core app.json scripts execution"
  local trigger="pre-deploy app_json_scripts"
  local APP="$1"; local IMAGE_TAG="$2"; local PHASE_SCRIPT_KEY="predeploy"

  dokku_log_info1 "Attempting to run scripts.dokku.$PHASE_SCRIPT_KEY from app.json (if defined)"
  execute_script "$APP" "$IMAGE_TAG" "$PHASE_SCRIPT_KEY"
}

exec_app_json_scripts "$@"
