Created
May 14, 2019 13:10
-
-
Save werty1st/66c7e346afa8bcdc6cf98ad84775b85d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
REPRODIR=/opt/app_build_repo | |
TARGET=/srv/www/htdocs/versions | |
FOUND_NEW=false | |
msg="" | |
cd $REPRODIR #change to git repo | |
git fetch --all #get all updates | |
git reset --hard origin/master #reset unclean state | |
tags=($(git tag | sort -V | tail -n13)) #convert list to array sort version numbers 2.10.0 > 2.2.0 | |
for tag in "${tags[@]}" | |
do | |
: | |
if [ ! -d $TARGET/$tag ] || [ -z "$(ls -A $TARGET/$tag)" ]; then | |
#Empty Dir Or not Existing | |
echo "Checkout new Version $tag" | |
msg="$msg\nCheckout new Version $tag" | |
mkdir -p $TARGET/$tag && git archive $tag | tar -x -C $TARGET/$tag | |
chmod -R 775 $TARGET/$tag | |
chown -R www-data $TARGET/$tag | |
FOUND_NEW=true | |
else | |
#Non Empty Dir | |
echo "Skip Version $tag" | |
msg="$msg\nSkip Version $tag" | |
fi | |
done | |
echo $(date "+%Y-%m-%d %H:%M:%S") > $TARGET/lastupdate.txt | |
#FOUND_NEW=true | |
if [ "$FOUND_NEW" = true ] ; then | |
echo 'Send Mail' | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment