Browse Source

Refactored dotorg deploy script to use svn cp (#5360)

Jason Crist 3 years ago
parent
commit
4e3a8837c4
1 changed files with 23 additions and 8 deletions
  1. 23 8
      deploy-dotorg.sh

+ 23 - 8
deploy-dotorg.sh

@@ -1,12 +1,12 @@
 #!/bin/bash
 
 # Make sure SVN credentials and project slug are set
-if [[ -z "$SVN_USERNAME" ]]; then
+if [[ -z "$SVN_USERNAME" ]] && [[ $1 != "preview" ]]; then
 	echo "Set the SVN_USERNAME secret"
 	exit 1
 fi
 
-if [[ -z "$SVN_PASSWORD" ]]; then
+if [[ -z "$SVN_PASSWORD" ]] && [[ $1 != "preview" ]]; then
 	echo "Set the SVN_PASSWORD secret"
 	exit 1
 fi
@@ -21,8 +21,9 @@ declare -a THEMES_TO_DEPLOY=(
 	"geologist"
 	"mayland-blocks"
 	"quadrat"
-	"skatepark"
-	"seedlet-blocks"
+	"seedlet-blocks",
+	"livro",
+	"videomaker"
 )
 
 for THEME_SLUG in ${THEMES_TO_DEPLOY[@]} ; do
@@ -57,8 +58,15 @@ for THEME_SLUG in ${THEMES_TO_DEPLOY[@]} ; do
 		continue;
 	fi
 
+	directories=($SVN_DIR/*)
+	last_directory=${directories[${#directories[@]}-1]}
+
+	echo "➤ Copying previous version of theme '${THEME_SLUG}' to svn repository... "
+	svn update --set-depth infinity ${last_directory} --non-interactive 
+	svn cp ${last_directory} $SVN_DIR/$THEME_VERSION
+
 	echo "➤ Copying theme '${THEME_SLUG}' version '${THEME_VERSION}' to svn repository... "
-	rsync -rc --include=theme.json --exclude-from './dotorg-exclude.txt' ./$THEME_SLUG/ $SVN_DIR/$THEME_VERSION
+	rsync -rc --delete --include=theme.json --exclude-from './dotorg-exclude.txt' ./$THEME_SLUG/ $SVN_DIR/$THEME_VERSION
 
 	# Remove -wpcom from versoning
 	find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/-wpcom//g' {} \; 
@@ -67,9 +75,16 @@ for THEME_SLUG in ${THEMES_TO_DEPLOY[@]} ; do
 	find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/, auto-loading-homepage//g' {} \; 
 	find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/, jetpack-global-styles//g' {} \; 
 
+	# Remove files from the previous version	
+	svn status $SVN_DIR/$THEME_VERSION | grep "^\!" | sed 's/^\! *//g' | xargs svn rm;
+
 	# Add the version to SVN
-	svn add $SVN_DIR --force > /dev/null
+	svn add $SVN_DIR/$THEME_VERSION --force --depth infinity -q > /dev/null
 
-	echo "➤ Committing files..."
-	svn commit $SVN_DIR -m "Update to version ${THEME_VERSION} from GitHub" --no-auth-cache --non-interactive  --username ${SVN_USERNAME} --password ${SVN_PASSWORD}
+ 	if [[ $1 == "preview" ]]; then
+		svn status $SVN_DIR
+	else
+		echo "➤ Committing files..."
+		svn commit $SVN_DIR -m "Update to version ${THEME_VERSION} from GitHub" --no-auth-cache --non-interactive  --username ${SVN_USERNAME} --password ${SVN_PASSWORD}
+	fi
 done