diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index 50e7fdb35..b0e77bded 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -587,6 +587,25 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x nginx -t ``` +### `pre-receive-app` + +- Description: Allows you to customize the contents of an application directory before they are processed for deployment. The `IMAGE_SOURCE_TYPE` can be any of `[herokuish, dockerfile]` +- Invoked by: `dokku git-hook`, `dokku tar-build-locked` +- Arguments: `$APP $IMAGE_SOURCE_TYPE $TMP_WORK_DIR` +- Example: + +```shell +#!/usr/bin/env bash +# Adds a file called `dokku-is-awesome` to the repository +# the contents will be the application name + +set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x + +APP="$1"; IMAGE_SOURCE_TYPE="$2"; TMP_WORK_DIR="$3" + +echo "$APP" > "$TMP_WORK_DIR/dokku-is-awesome" +``` + ### `receive-app` - Description: Allows you to customize what occurs when an app is received. Normally just triggers an application build. diff --git a/plugins/20_events/pre-receive-app b/plugins/20_events/pre-receive-app new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/pre-receive-app @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/git/commands b/plugins/git/commands index ff2c4c094..783813f12 100755 --- a/plugins/git/commands +++ b/plugins/git/commands @@ -21,8 +21,10 @@ git_build_app_repo() { find -name .git -prune -exec rm -rf {} \; > /dev/null if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then + plugn trigger pre-receive-app "$APP" "dockerfile" "$TMP_WORK_DIR" dokku receive "$APP" "dockerfile" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" else + plugn trigger pre-receive-app "$APP" "herokuish" "$TMP_WORK_DIR" dokku receive "$APP" "herokuish" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" fi } diff --git a/plugins/tar/commands b/plugins/tar/commands index 519ae4e15..c5773ec17 100755 --- a/plugins/tar/commands +++ b/plugins/tar/commands @@ -52,8 +52,10 @@ case "$1" in chmod -R u+r "$TMP_WORK_DIR" if [[ -f Dockerfile ]] && [[ "$([[ -f .env ]] && grep -q BUILDPACK_URL .env; echo $?)" != "0" ]] && [[ ! -f ".buildpacks" ]]; then + plugn trigger pre-receive-app "$APP" "dockerfile" "$TMP_WORK_DIR" dokku receive "$APP" "dockerfile" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" else + plugn trigger pre-receive-app "$APP" "herokuish" "$TMP_WORK_DIR" dokku receive "$APP" "herokuish" "$TMP_WORK_DIR" | sed -u "s/^/"$'\e[1G'"/" fi ;;