-
Notifications
You must be signed in to change notification settings - Fork 26
/
post-extract
executable file
·33 lines (23 loc) · 1.01 KB
/
post-extract
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
APP="$1"; TMP_WORK_DIR="$2"; REV="$3"
[[ ! -f "$TMP_WORK_DIR/.dokku-monorepo" ]] && exit
dokku_log_info2 "Monorepo detected"
while IFS="=" read -u 10 -a line || [[ -n $line ]]; do
[[ "${line[0]}" == "#"* || "${line[1]}" == "" ]] && continue
[[ $APP != *"${line[0]}"* ]] && continue
app_subdir="${line[1]}"
dokku_log_info2 "Installing from ./$app_subdir"
# Move the app we want to deploy to a temp directory.
app_tmp_dir="$(mktemp -d)"
mv -T "$TMP_WORK_DIR/$app_subdir" "$app_tmp_dir/app"
# Delete all files that aren't related to the app we are trying to deploy
find "$TMP_WORK_DIR" -mindepth 1 -delete
# Move the app back into the TMP_WORK_DIR
find "$app_tmp_dir/app" -mindepth 1 -maxdepth 1 -print0 | xargs -0 mv -t "$TMP_WORK_DIR"
rm -rf "$app_tmp_dir"
exit
done 10<"$TMP_WORK_DIR/.dokku-monorepo"
dokku_log_info2 "The application $APP is not defined in .dokku-monorepo!"
exit 1