Skip to content

Commit

Permalink
feat: Add hook folder configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fteychene committed Jun 16, 2020
1 parent f81ddb0 commit d8488e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ dokku plugin:install https://github.com/fteychene/dokku-build-hook.git build-hoo

The plugin will search for scripts in application codebase to be executed on different phases of the build.

The scripts should be installed in a `hooks` directory in the project codebase and be name as the corresponding hook you want to trigger.
By default, the scripts should be installed in a `hooks` directory in the project codebase and be named as the corresponding hook you want to trigger.


Hooks :
- [x] pre-build : This script will be executed before the build of the project (Buildpack or Dockerfile based)


### Configuration

The folder where scripts are loaded could be overrided by setting `HOOKS_DIR` configuration for application


## Example

Add a script `hooks/pre-build` in a dokku project.
Expand Down
18 changes: 12 additions & 6 deletions pre-build
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_CORE_AVAILABLE_PATH/config/functions"

APP="$1";
dokku_log_info1 "Checking for pre-build script"
if [ -f "hooks/pre-build" ]; then
if [ ! -x "hooks/pre-build" ]; then
dokku_log_warn "Adding missing execution permission. Please change the permission on your codebase."
chmod +x hooks/pre-build
# Load configuration to be available
eval "$(config_export app "$APP")"

HOOKS_DIR=${HOOKS_DIR:-hooks}

dokku_log_info1 "Checking for pre-build script in $HOOKS_DIR"
if [ -f "$HOOKS_DIR/pre-build" ]; then
if [ ! -x "$HOOKS_DIR/pre-build" ]; then
dokku_log_warn "Adding missing execution permission. Please check your permissions."
chmod +x $HOOKS_DIR/pre-build
fi
dokku_log_info2 "Running pre-build script"
hooks/pre-build
$HOOKS_DIR/pre-build
dokku_log_info2 "End of pre-build script"
fi

0 comments on commit d8488e6

Please sign in to comment.