From 7d31c4fc1ebf53653f4da9c66f6d7e15ad00f39c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Oct 2015 00:11:29 -0400 Subject: [PATCH 1/2] Add pre-receive-app plugin trigger Users can modify the temporary working directory to add or remove any necessary files before an application is processed for deployment. --- plugins/20_events/pre-receive-app | 1 + plugins/git/commands | 2 ++ plugins/tar/commands | 2 ++ 3 files changed, 5 insertions(+) create mode 120000 plugins/20_events/pre-receive-app 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 ;; From c793dca61aca2efe1b8ca908557c549c032ad72c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Oct 2015 00:20:54 -0400 Subject: [PATCH 2/2] Add documentation for pre-receive-app trigger [ci skip] --- docs/development/plugin-triggers.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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.