#!/bin/bash
set -eo pipefail

repository=$1
app=${1%.git}
sha=$2
username=$3
fingerprint=$4

curl \
  -X 'POST' --fail \
  -H 'Content-Type: application/json' \
  -H "X-Deis-Builder-Auth: {{ .deis_controller_builderKey }}" \
  -d "{\"receive_user\": \"$username\", \"receive_repo\": \"$app\", \"sha\": \"$sha\", \"fingerprint\": \"$fingerprint\", \"ssh_connection\": \"$SSH_CONNECTION\", \"ssh_original_command\": \"$SSH_ORIGINAL_COMMAND\"}" \
  --silent http://{{ .deis_controller_host }}:{{ .deis_controller_port }}/api/hooks/push >/dev/null
