diff --git a/README.md b/README.md index 33554da..4cb0816 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This Action commits the contents of your Git tag to the WordPress.org plugin rep * `SLUG` - defaults to the repository name, customizable in case your WordPress repository has a different slug or is capitalized differently. * `VERSION` - defaults to the tag name; do not recommend setting this except for testing purposes. * `ASSETS_DIR` - defaults to `.wordpress-org`, customizable for other locations of WordPress.org plugin repository-specific assets that belong in the top-level `assets` directory (the one on the same level as `trunk`). +* `WORKSPACE_DIR` - defaults to `$GITHUB_WORKSPACE`, customizable for other locations. ## Excluding files from deployment If there are files or directories to be excluded from deployment, such as tests or editor config files, they can be specified in either a `.distignore` file or a `.gitattributes` file using the `export-ignore` directive. If a `.distignore` file is present, it will be used; if not, the Action will look for a `.gitattributes` file and barring that, will write a basic temporary `.gitattributes` into place before proceeding so that no Git/GitHub-specific files are included. diff --git a/entrypoint.sh b/entrypoint.sh index 6389c15..8062f09 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -46,6 +46,11 @@ if [[ -z "$ASSETS_DIR" ]]; then fi echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR" +if [[ -z "$WORKSPACE_DIR" ]]; then + WORKSPACE_DIR=$GITHUB_WORKSPACE +fi +echo "ℹ︎ WORKSPACE_DIR is $WORKSPACE_DIR" + SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/" SVN_DIR="/github/svn-${SLUG}" @@ -57,16 +62,20 @@ cd "$SVN_DIR" svn update --set-depth infinity assets svn update --set-depth infinity trunk +echo "➤ Current working directory" +pwd + echo "➤ Copying files..." 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" "$WORKSPACE_DIR/" trunk/ --delete --delete-excluded else echo "ℹ︎ Using .gitattributes" cd "$GITHUB_WORKSPACE" + cd "$WORKSPACE_DIR" # "Export" a cleaned copy to a temp directory TMP_DIR="/github/archivetmp" @@ -84,7 +93,7 @@ else /.github export-ignore EOL - # Ensure we are in the $GITHUB_WORKSPACE directory, just in case + # Ensure we are in the $WORKSPACE_DIR directory, just in case # The .gitattributes file has to be committed to be used # Just don't push it to the origin repo :) git add .gitattributes && git commit -m "Add .gitattributes file" @@ -123,8 +132,10 @@ 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 +if test -n "$(find . -maxdepth 1 -name 'glob*' -print -quit)"; then + svn propset svn:mime-type image/png assets/*.png || true + svn propset svn:mime-type image/jpeg assets/*.jpg || true +fi svn status