-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
199 changed files
with
5,345 additions
and
39,978 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 |
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
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!" |
Oops, something went wrong.
cd8fd44
There was a problem hiding this comment.
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