Created
June 10, 2013 06:56
-
-
Save maartenba/5746980 to your computer and use it in GitHub Desktop.
Deployment script for Windows Azure Web SItes running PHPUnit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ---------------------- | |
# KUDU Deployment Script | |
# ---------------------- | |
# Helpers | |
# ------- | |
exitWithMessageOnError () { | |
if [ ! $? -eq 0 ]; then | |
echo "An error has occured during web site deployment." | |
echo $1 | |
exit 1 | |
fi | |
} | |
# Prerequisites | |
# ------------- | |
# Verify node.js installed | |
where node &> /dev/null | |
exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment." | |
# Setup | |
# ----- | |
SCRIPT_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
ARTIFACTS=$SCRIPT_DIR/artifacts | |
if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then | |
DEPLOYMENT_SOURCE=$SCRIPT_DIR | |
fi | |
if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then | |
NEXT_MANIFEST_PATH=$ARTIFACTS/manifest | |
if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then | |
PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH | |
fi | |
fi | |
if [[ ! -n "$KUDU_SYNC_COMMAND" ]]; then | |
# Install kudu sync | |
echo Installing Kudu Sync | |
npm install kudusync -g --silent | |
exitWithMessageOnError "npm failed" | |
KUDU_SYNC_COMMAND="kuduSync" | |
fi | |
if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then | |
DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot | |
else | |
# In case we are running on kudu service this is the correct location of kuduSync | |
KUDU_SYNC_COMMAND="$APPDATA\\npm\\node_modules\\kuduSync\\bin\\kuduSync" | |
fi | |
echo Download composer. | |
curl -O https://getcomposer.org/composer.phar > /dev/null | |
echo Run composer update. | |
cd "$DEPLOYMENT_SOURCE" | |
"D:\Program Files (x86)\PHP\v5.4\php.exe" composer.phar update --optimize-autoloader | |
################################################################################################################################## | |
# Testing | |
# ------- | |
echo Running PHPUnit tests. | |
# 1. PHPUnit | |
"D:\Program Files (x86)\PHP\v5.4\php.exe" -d auto_prepend_file="$DEPLOYMENT_SOURCE\\vendor\\autoload.php" "$DEPLOYMENT_SOURCE\\vendor\\phpunit\\phpunit\\phpunit.php" --configuration "$DEPLOYMENT_SOURCE\\app\\phpunit.xml" | |
exitWithMessageOnError "PHPUnit tests failed" | |
echo | |
################################################################################################################################## | |
# Deployment | |
# ---------- | |
echo Handling Basic Web Site deployment. | |
# 1. KuduSync | |
echo Kudu Sync from "$DEPLOYMENT_SOURCE" to "$DEPLOYMENT_TARGET" | |
$KUDU_SYNC_COMMAND -q -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.deployment;deploy.sh" | |
exitWithMessageOnError "Kudu Sync failed" | |
################################################################################################################################## | |
echo "Finished successfully." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment