Last active
March 7, 2017 07:24
-
-
Save ahmadajmi/a286ab6fe82b4f926fbb83d7b0fe519c to your computer and use it in GitHub Desktop.
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 | |
# Get Those From Arguments | |
THEME=$1 | |
THEME_VERSION=$2 | |
# Split Theme into Name and Type | |
THEME_NAME=${THEME%-*} | |
THEME_TYPE=${THEME#*-} | |
# Remote Server Settings | |
GHOST_IP_ADDRESS=159.203.90.215 | |
WORDPRESS_IP_ADDRESS=107.170.4.135 | |
GHOST_REMOTE_THEMES_DIR=/var/www/$THEME_NAME/content/themes/ | |
WORDPRESS_REMOTE_THEMES_DIR=/srv/users/serverpilot/apps/$THEME_NAME/public/wp-content/themes/ | |
LOCAL_THEMES_DIR=~ | |
# Define themes local directory | |
if [ $THEME_TYPE = 'wordpress' ] | |
then | |
LOCAL_THEMES_DIR=$HOME/www/aspire/wp-content/themes/ | |
elif [ $THEME_TYPE = 'ghost' ] | |
then | |
LOCAL_THEMES_DIR=$HOME/www/ghost/apps/ghost/htdocs/content/themes/ | |
cd $LOCAL_THEMES_DIR | |
ZIP_COMMAND=$(zip -r $THEME_NAME.zip $THEME_NAME -x *node_modules* *git* *.DS_Store* *.ds_store*) | |
elif [ $THEME_TYPE = 'jekyll' ] | |
then | |
LOCAL_THEMES_DIR=$HOME/www/ | |
cd $LOCAL_THEMES_DIR | |
ZIP_COMMAND=$(zip -r $THEME_NAME.zip east -x *git* *.DS_Store* *.ds_store* *.sass-cache* *_site* *_posts/*.** *images/posts/*.** *images/pages/*.** *_pages/style-guide.md*) | |
fi | |
##============================================ | |
# Zip the Theme | |
##============================================ | |
cd $LOCAL_THEMES_DIR | |
ZIP_COMMAND=$(zip -r $THEME_NAME.zip $THEME_NAME -x *git* *node_modules* *bower_components* *.DS_Store* *.ds_store* *.editorconfig* *.jshintignore* *.jshintrc* *.vscode* *.vscode* *screenshot.png*) | |
rm -rf $THEME_NAME.zip | |
echo "===>> Removed $THEME_NAME.zip β" | |
zip -r $THEME_NAME.zip $THEME_NAME -x *git* *node_modules* *bower_components* *.DS_Store* *.ds_store* *.editorconfig* *.jshintignore* *.jshintrc* *.vscode* *.vscode* #*screenshot.png* | |
echo "===>> Zipped WordPress theme to $THEME_NAME.zip π¦" | |
##============================================ | |
# Move the Theme to Dropbox Folder With | |
# Version Name to Be Ready for Themeforest | |
##============================================ | |
FINAL_THEME_DIR=$HOME/Dropbox/AspireThemes/Themes/WordPress/$THEME_NAME/$THEME_NAME-$THEME_VERSION | |
mkdir $FINAL_THEME_DIR | |
echo "===>> $FINAL_THEME_DIR is created π¨" | |
cp -rf $THEME_NAME.zip $FINAL_THEME_DIR | |
echo '===>> You Are Ready to Submit to Themeforest πππ' | |
echo '===>> Please Go Submit to Themeforest and Comeback and Hit ENTER π To Update Theme Docs & π to GitHub!' | |
##============================================ | |
# Update Theme Docs Version and Push to Github | |
##============================================ | |
read | |
echo 'Now We Are Going to Update Theme Docs and Push to Github π π π' | |
ASPIRETHEMES_DIR=$HOME/www/aspirethemes | |
ASPIRETHEMES_DOCS_DIR=$HOME/www/aspirethemes/_docs | |
THEME_DOC_FILE=$ASPIRETHEMES_DOCS_DIR/$THEME.md | |
CURRENT_VERSION="Current Version:" | |
NEW_VERSION="Current Version: $THEME_VERSION" | |
perl -pi -e "s/$CURRENT_VERSION\s.*$/$NEW_VERSION/g" $THEME_DOC_FILE | |
git -C $ASPIRETHEMES_DIR commit -am "Updated $THEME Theme Docs to Version: $THEME_VERSION" | |
git -C $ASPIRETHEMES_DIR push | |
echo '===>> Updated the Docs and Pushed to GitHub ππ' | |
echo '===>> You are ready to push the theme to the server, you can now hit π to push changes to the server πππ' | |
##============================================ | |
# Push Theme to the Remote Server | |
##============================================ | |
read | |
echo '===>> Now We Are Going to Push to the Server ππ' | |
scp $THEME_NAME.zip root@$WORDPRESS_IP_ADDRESS:$WORDPRESS_REMOTE_THEMES_DIR | |
echo '===>> Pushed to the server π' | |
ssh -t -t root@$WORDPRESS_IP_ADDRESS << EOT | |
cd $WORDPRESS_REMOTE_THEMES_DIR | |
echo $THEME_NAME | |
rm -rf $THEME_NAME | |
echo "===>> Removed $THEME_NAME" | |
unzip -o $THEME_NAME.zip | |
echo '===>> Un Zipped' | |
rm -rf $THEME_NAME.zip | |
echo "===>> Removed $THEME_NAME.zip" | |
echo '===>> Done π' | |
exit 1 | |
EOT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment