Skip to content
Snippets Groups Projects

Add support for WP.org's static assets

Merged Erick Hitter requested to merge add/assets into master
2 files
+ 35
11
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 24
10
@@ -6,38 +6,47 @@
# it does not exit with a 0, and I only care about the final exit.
set -eo
# Ensure SVN username and password are set
# IMPORTANT: while secrets are encrypted and not viewable in the GitHub UI,
# they are by necessity provided as plaintext in the context of the Action,
# so do not echo or use debug mode unless you want your secrets exposed!
# Provide a basic version identifier, particularly since this script
# is usually accessed via CDN.
echo "ℹ︎ WP-ORG-PLUGIN-DEPLOY VERSION: 2019041401"
if [[ -z "$CI" ]]; then
echo "Script is only to be run by GitLab CI" 1>&2
echo "𝘅︎ Script is only to be run by GitLab CI" 1>&2
exit 1
fi
# Ensure certain environment variables are set
# IMPORTANT: while access to secrets is restricted in the GitLab UI,
# they are by necessity provided as plaintext in the context of this script,
# so do not echo or use debug mode unless you want your secrets exposed!
if [[ -z "$WP_ORG_USERNAME" ]]; then
echo "WordPress.org username not set" 1>&2
echo "𝘅︎ WordPress.org username not set" 1>&2
exit 1
fi
if [[ -z "$WP_ORG_PASSWORD" ]]; then
echo "WordPress.org password not set" 1>&2
echo "𝘅︎ WordPress.org password not set" 1>&2
exit 1
fi
if [[ -z "$PLUGIN_SLUG" ]]; then
echo "Plugin's SVN slug is not set" 1>&2
echo "𝘅︎ Plugin's SVN slug is not set" 1>&2
exit 1
fi
if [[ -z "$PLUGIN_VERSION" ]]; then
echo "Plugin's version is not set" 1>&2
echo "𝘅︎ Plugin's version is not set" 1>&2
exit 1
fi
if [[ -z "$WP_ORG_ASSETS_DIR" ]]; then
WP_ORG_ASSETS_DIR=".wordpress-org"
fi
echo "ℹ︎ PLUGIN_SLUG: $PLUGIN_SLUG"
echo "ℹ︎ PLUGIN_VERSION: $PLUGIN_VERSION"
echo "ℹ︎ WP_ORG_RELEASE_REF: $WP_ORG_RELEASE_REF"
echo "ℹ︎ WP_ORG_ASSETS_DIR: $WP_ORG_ASSETS_DIR"
SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}/"
SVN_DIR="$CI_BUILDS_DIR/svn-${PLUGIN_SLUG}"
@@ -47,6 +56,7 @@ TMP_DIR="$CI_BUILDS_DIR/git-archive"
echo "➤ Checking out dotorg repository..."
svn checkout --depth immediates "$SVN_URL" "$SVN_DIR"
cd "$SVN_DIR"
svn update --set-depth infinity assets
svn update --set-depth infinity trunk
svn update --set-depth infinity "tags/${PLUGIN_VERSION}"
@@ -60,9 +70,10 @@ git config --global user.name "Erick Hitter (GitLab CI)"
# If there's no .gitattributes file, write a default one into place
if [[ ! -e "$CI_PROJECT_DIR/.gitattributes" ]]; then
cat > "$CI_PROJECT_DIR/.gitattributes" <<-EOL
/${WP_ORG_ASSETS_DIR} export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
/.gitlab-ci.yml export-ignore
EOL
# The .gitattributes file has to be committed to be used
@@ -80,6 +91,9 @@ cd "$SVN_DIR"
# The --delete flag will delete anything in destination that no longer exists in source
rsync -r "$TMP_DIR/" trunk/ --delete
# Copy dotorg assets to /assets
rsync -r "${CI_PROJECT_DIR}/${WP_ORG_ASSETS_DIR}/" assets/ --delete
# Add everything and commit to SVN
# The force flag ensures we recurse into subdirectories even if they are already added
# Suppress stdout in favor of svn status later for readability
Loading