Skip to content
Closed
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 15 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand All @@ -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
Copy link
Contributor

@dinhtungdu dinhtungdu Jan 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, we're in the $SNV_DIR, if $WORKSPACE_DIR is set to a relative path, this this command will fail.

Copy link
Author

@Lewiscowles1986 Lewiscowles1986 Jan 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and my other PR have been working since 2020. Thank you for your input. I am closing this PR.

else
echo "ℹ︎ Using .gitattributes"

cd "$GITHUB_WORKSPACE"
cd "$WORKSPACE_DIR"

# "Export" a cleaned copy to a temp directory
TMP_DIR="/github/archivetmp"
Expand All @@ -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"
Expand Down Expand Up @@ -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

Expand Down