Skip to content

Commit

Permalink
Merge pull request #37 from shivapoudel/add/zip-path-output
Browse files Browse the repository at this point in the history
Add zip generation steps to output zip_path, Closes #34
  • Loading branch information
helen authored May 26, 2020
2 parents 23b5cc4 + 83b32ae commit d5acdd9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
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!"

0 comments on commit d5acdd9

Please sign in to comment.