Skip to content

Commit

Permalink
Merge branch 'canary' into site-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
blakewilson committed Nov 5, 2021
2 parents 6f26203 + aee4bc5 commit cd8fd44
Show file tree
Hide file tree
Showing 199 changed files with 5,345 additions and 39,978 deletions.
263 changes: 0 additions & 263 deletions .circleci/config.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/actions/release-plugin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'WordPress Plugin Deploy'
description: 'Deploy to the WordPress Plugin Repository'
author: '10up'
branding:
icon: 'upload-cloud'
color: 'blue'
inputs:
generate-zip:
description: 'Generate package zip file?'
default: false
outputs:
zip-path:
description: 'Path to zip file'
value: ${{ steps.deploy.outputs.zip-path }}
runs:
using: 'composite'
steps:
- id: deploy
env:
INPUT_GENERATE_ZIP: ${{ inputs.generate-zip }}
run: ${{ github.action_path }}/deploy.sh
shell: bash
108 changes: 108 additions & 0 deletions .github/actions/release-plugin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/bin/bash

# Note that this does not use pipefail
# because if the grep later doesn't match any deleted files,
# which is likely the majority case,
# 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!
if [[ -z "$SVN_USERNAME" ]]; then
echo "Set the SVN_USERNAME secret"
exit 1
fi

if [[ -z "$SVN_PASSWORD" ]]; then
echo "Set the SVN_PASSWORD secret"
exit 1
fi

# Require the PLUGIN_DIR environment variable to be set
if [[ -z "$PLUGIN_DIR" ]]; then
echo "Set the PLUGIN_DIR environment variable"
exit 1
fi
echo "ℹ︎ PLUGIN_DIR is $PLUGIN_DIR"

# Allow some ENV variables to be customized
if [[ -z "$SLUG" ]]; then
SLUG=${GITHUB_REPOSITORY#*/}
fi
echo "ℹ︎ SLUG is $SLUG"

# Does it even make sense for VERSION to be editable in a workflow definition?
if [[ -z "$VERSION" ]]; then
VERSION="${GITHUB_REF#refs/tags/}"
VERSION="${VERSION#v}"
fi
echo "ℹ︎ VERSION is $VERSION"

if [[ -z "$ASSETS_DIR" ]]; then
ASSETS_DIR=".wordpress-org"
fi
echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR"

SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/"
SVN_DIR="${HOME}/svn-${SLUG}"

# Checkout just trunk and assets for efficiency
# Tagging will be handled on the SVN level
echo "➤ Checking out .org repository..."
svn checkout --depth immediates "$SVN_URL" "$SVN_DIR"
cd "$SVN_DIR"
svn update --set-depth infinity assets
svn update --set-depth infinity trunk

echo "➤ Copying files..."
if [[ -e "$GITHUB_WORKSPACE/$PLUGIN_DIR/.distignore" ]]; then
echo "ℹ︎ Using .distignore"
# Copy from PLUGIN_DIR to /trunk, excluding dotorg assets
# The --delete flag will delete anything in destination that no longer exists in source
rsync -rc --exclude-from="$GITHUB_WORKSPACE/$PLUGIN_DIR/.distignore" "$GITHUB_WORKSPACE/$PLUGIN_DIR" trunk/ --delete --delete-excluded
else
rsync -rc "$GITHUB_WORKSPACE/$PLUGIN_DIR" trunk --delete --delete-excluded
fi

# Copy dotorg assets to /assets
if [[ -d "$GITHUB_WORKSPACE/$PLUGIN_DIR/$ASSETS_DIR/" ]]; then
rsync -rc "$GITHUB_WORKSPACE/$PLUGIN_DIR/$ASSETS_DIR/" assets/ --delete
else
echo "ℹ︎ No assets directory found; skipping asset copy"
fi

# 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
echo "➤ Preparing files..."
svn add . --force > /dev/null

# SVN delete all deleted files
# Also suppress stdout here
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %@ > /dev/null

# Copy tag locally to make this a single commit
echo "➤ Copying tag..."
svn cp "trunk" "tags/$VERSION"

# Fix screenshots getting force downloaded when clicking them
# https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/
svn propset svn:mime-type image/png assets/*.png || true
svn propset svn:mime-type image/jpeg assets/*.jpg || true

svn status

echo "➤ Committing files..."
svn commit -m "Update to version $VERSION from GitHub" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"

if $INPUT_GENERATE_ZIP; then
echo "Generating zip file..."
cd "$SVN_DIR/trunk" || exit
zip -r "${GITHUB_WORKSPACE}/${PLUGIN_DIR}/${SLUG}.zip" .
echo "::set-output name=zip-path::${GITHUB_WORKSPACE}/${PLUGIN_DIR}/${SLUG}.zip"
echo "✓ Zip file generated!"
fi

echo "✓ Plugin deployed!"
Loading

1 comment on commit cd8fd44

@headless-platform-by-wp-engine

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Branch site-dev was deployed successfully
Your environment Development of app faustjs-site was successfully updated
View build logs: https://my.wpengine.com/atlas#/faustjs-site/cixzyt38dn5ak04xxcqc36lf/96sgzb993ipqyzv0oheqjxtl
View your environment URL: https://hcixzyt38dn5ak04xxcqc36lf.js.wpenginepowered.com

Please sign in to comment.