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
21 changes: 13 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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 @@ -50,15 +55,15 @@ svn update --set-depth infinity assets
svn update --set-depth infinity trunk

echo "➤ Copying files..."
if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
if [[ -e "$WORKSPACE_DIR/.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="$WORKSPACE_DIR/.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"
Expand All @@ -68,15 +73,15 @@ else
git config --global user.name "10upbot on GitHub"

# If there's no .gitattributes file, write a default one into place
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
if [[ ! -e "$WORKSPACE_DIR/.gitattributes" ]]; then
cat > "$WORKSPACE_DIR/.gitattributes" <<-EOL
/$ASSETS_DIR export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.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 All @@ -93,8 +98,8 @@ else
fi

# Copy dotorg assets to /assets
if [[ -d "$GITHUB_WORKSPACE/$ASSETS_DIR/" ]]; then
rsync -rc "$GITHUB_WORKSPACE/$ASSETS_DIR/" assets/ --delete
if [[ -d "$WORKSPACE_DIR/$ASSETS_DIR/" ]]; then
rsync -rc "$WORKSPACE_DIR/$ASSETS_DIR/" assets/ --delete
else
echo "ℹ︎ No assets directory found; skipping asset copy"
fi
Expand Down