diff --git a/Dockerfile b/Dockerfile index 44c0718..8110578 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/action.yml b/action.yml index a70878c..0f56fdb 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/entrypoint.sh b/entrypoint.sh index 48af7e2..8dfc2a3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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#*/} @@ -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" @@ -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!"