浏览代码

Fix dotorg deploy script (#8020)

* Attempt to fix dotorg deploy script

* Check theme has been approved before attempting to update

* Revert change to wpcom specific tags line

* Fix spacing

* remove trailing slashes

* Update deploy-dotorg.sh

Co-authored-by: Vicente Canales <1157901+vcanales@users.noreply.github.com>

* Add check to compare version numbers already deployed

* Remove decimals from versions before comparing

---------

Co-authored-by: Vicente Canales <1157901+vcanales@users.noreply.github.com>
Sarah Norris 11 月之前
父节点
当前提交
668cc7da29
共有 1 个文件被更改,包括 18 次插入0 次删除
  1. 18 0
      deploy-dotorg.sh

+ 18 - 0
deploy-dotorg.sh

@@ -36,6 +36,9 @@ rm -rf ./deploy
 # Do things for all of the themes
 for THEME_SLUG in */ ; do
 
+	# Remove slashes from the theme slug
+	THEME_SLUG=$(echo $THEME_SLUG | tr -d '/')
+
 	# Skip any classic themes (assuming that none of our classic themes use a theme.json file)
 	if ! test -f "./${THEME_SLUG}/theme.json"; then
 		# echo "Ignoring classic theme ${THEME_SLUG}. Moving on."
@@ -58,9 +61,16 @@ for THEME_SLUG in */ ; do
 		  | sed 's/-wpcom//g' \
 		  | tr -d '[[:space:]]')
 
+		DIRECTORY_URL="https://wordpress.org/themes/${THEME_SLUG}/"
 		SVN_URL="https://themes.svn.wordpress.org/${THEME_SLUG}/"
 		SVN_DIR="$PWD/deploy/${THEME_SLUG}"
 
+		response=$(curl -s -o /dev/null -w "%{http_code}" "$DIRECTORY_URL")
+		if [ "$response" != "200" ]; then
+			# echo "Theme with slug ${THEME_SLUG} has not been approved to the themes directory. Moving on."
+			continue;
+		fi
+
 		response=$(curl -s -o /dev/null -w "%{http_code}" "$SVN_URL")
 		if [ "$response" != "200" ]; then
 			# echo "No theme with slug ${THEME_SLUG} to be updated. Moving on."
@@ -91,6 +101,14 @@ for THEME_SLUG in */ ; do
 		last_directory=${directories[${#directories[@]}-1]}
 		last_version="${last_directory##*/}"
 
+		# Check if last_version is a later version than THEME_VERSION
+		theme_version_without_decimal=$(echo $THEME_VERSION | tr -d '.')
+		last_version_without_decimal=$(echo $last_version | tr -d '.')
+		if (( last_version_without_decimal > theme_version_without_decimal )); then
+			echo "${THEME_SLUG} version '${last_version}' is newer than '${THEME_VERSION}', so it must not need updating.  Moving on."
+			continue;
+		fi
+
 		echo "➤ Upgrading ${THEME_SLUG} from ${last_version} to $THEME_VERSION"
 
 	 	if [[ $1 == "preview" ]]; then