introduce automated deployment
This commit is contained in:
parent
2b907cf675
commit
178b75f453
2 changed files with 68 additions and 1 deletions
67
deploy.sh
Normal file
67
deploy.sh
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Abort if a command fails!
|
||||
set -e
|
||||
|
||||
TEMP_DIR=/tmp/
|
||||
|
||||
if [ ! -n "$HOST" ];then
|
||||
echo "missing option \"HOST\", aborting"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -n "$USER" ];then
|
||||
echo "missing option \"HOST\", aborting"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -n "$PASSWORD" ];then
|
||||
echo "missing option \"HOST\", aborting"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -n "$IGNORE" ];then
|
||||
IGNORE=''
|
||||
fi
|
||||
|
||||
# Create temporary director
|
||||
WORKING_DIR="$TEMP_DIR/workspace"
|
||||
|
||||
# TODO: fail if exists..
|
||||
mkdir -p $WORKING_DIR
|
||||
export COMPOSER_HOME="$WORKING_DIR"
|
||||
|
||||
# Clone the repo & checkout branch
|
||||
echo "Creating archive..."
|
||||
git archive master --format=tar --output=$TEMP_DIR/export.tar
|
||||
tar -xf $TEMP_DIR/export.tar -C $WORKING_DIR
|
||||
|
||||
# Change directory into the working dir
|
||||
cd "$WORKING_DIR"
|
||||
|
||||
# install the dependencies
|
||||
echo "Install dependencies..."
|
||||
composer install --no-dev --optimize-autoloader
|
||||
|
||||
# Prepare ignore parameters
|
||||
IFS=';' read -a igor <<< "$IGNORE"
|
||||
params=''
|
||||
for element in "${igor[@]}"
|
||||
do
|
||||
params=$(echo "$params --exclude $element")
|
||||
done
|
||||
|
||||
# TODO: allow SFTP
|
||||
# TODO: allow verify cert
|
||||
echo "Uploading..."
|
||||
lftp -e "
|
||||
open $HOST
|
||||
set ssl:verify-certificate no
|
||||
set ftp:ssl-allow off
|
||||
set cmd:fail-exit true
|
||||
user $USER $PASSWORD
|
||||
cd $DIRECTORY
|
||||
mirror --reverse $params --delete --ignore-time --verbose --parallel . .
|
||||
bye
|
||||
"
|
||||
|
||||
# Complete!
|
||||
echo "Done!"
|
||||
exit 0
|
|
@ -1,4 +1,4 @@
|
|||
box: raphiz/drone-php:5.5.20
|
||||
box: raphiz/passwordcards
|
||||
build:
|
||||
steps:
|
||||
- script:
|
||||
|
|
Reference in a new issue