Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zip generation steps to output zip_path, Closes #34 #37

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM debian:stable-slim

RUN apt-get update \
&& apt-get install -y subversion rsync git \
&& apt-get install -y subversion rsync git zip \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
name: 'WordPress Plugin Deploy'
description: 'Deploy to the WordPress Plugin Repository'
author: '10up'
inputs:
generate-zip:
description: 'Generate package zip file?'
default: false
outputs:
zip_path:
description: 'Zip file path'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.generate-zip }}
branding:
icon: 'upload-cloud'
color: 'blue'
19 changes: 18 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ if [[ -z "$SVN_PASSWORD" ]]; then
exit 1
fi

# Set variables
GENERATE_ZIP=false

# Set options based on user input
if [ -z "$1" ]; then
GENERATE_ZIP=$1;
fi

# Allow some ENV variables to be customized
if [[ -z "$SLUG" ]]; then
SLUG=${GITHUB_REPOSITORY#*/}
Expand Down Expand Up @@ -54,7 +62,7 @@ if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
echo "ℹ︎ Using .distignore"
# Copy from current branch 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/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded
rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded
else
echo "ℹ︎ Using .gitattributes"

Expand Down Expand Up @@ -118,4 +126,13 @@ 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 ! $GENERATE_ZIP; then
echo "Generating zip file..."
cd "$SVN_DIR/trunk" || exit
zip -r "${SLUG}.zip" "$SLUG/"
# Set GitHub "zip_path" output
echo "::set-output name=zip_path::$SVN_DIR/${SLUG}.zip"
echo "✓ Zip file generated!"
fi

echo "✓ Plugin deployed!"