Files
dokku/tests/test_deploy

50 lines
1.0 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
2015-01-03 10:55:40 -08:00
set -xeo pipefail
2014-12-13 18:56:31 -08:00
SELF=$(which $0); APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"
2013-12-11 21:41:05 +00:00
REMOTE="dokku@$TARGET"
REPO="test-$(basename $APP)-$RANDOM"
2014-12-13 18:56:31 -08:00
destroy_app(){
echo $REPO | ssh $REMOTE apps:destroy $REPO
}
failed(){
2014-12-14 14:55:26 -08:00
echo "************ $1 failed ************"
2014-12-16 17:37:43 -08:00
destroy_app
2014-12-13 18:56:31 -08:00
exit 1
}
2013-06-23 03:37:00 -07:00
TMP=$(mktemp -d -t "$TARGET.XXXXX")
2014-12-13 18:56:31 -08:00
rmdir $TMP && cp -r "$(dirname "$SELF")"/$APP $TMP
cd $TMP
git init
2013-06-23 03:45:45 -07:00
git config user.email "robot@example.com"
git config user.name "Test Robot"
2013-12-11 21:41:05 +00:00
git remote add target $REMOTE:$REPO
[[ -f gitignore ]] && mv gitignore .gitignore
git add .
2013-12-11 21:41:05 +00:00
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
git commit -m 'initial commit'
2014-12-14 14:45:49 -08:00
git push target master || failed git-push
2014-12-13 18:56:31 -08:00
if [[ -x post-deploy ]]; then
./post-deploy $REMOTE $REPO || failed post-deploy
fi
2013-12-11 21:41:05 +00:00
2014-12-14 14:45:49 -08:00
URL=$(dokku url $REPO)$FORWARDED_PORT
sleep 2
2014-12-13 18:56:31 -08:00
if (./check_deploy $URL); then
echo "-----> Deploy success!"
else
2013-06-30 02:27:36 -05:00
sleep 4
2014-12-13 18:56:31 -08:00
if (./check_deploy $URL); then
echo "-----> Deploy success!"
else
failed check-deploy
fi
fi
2013-12-11 21:41:05 +00:00
2014-12-13 18:56:31 -08:00
destroy_app