Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ If there are files or directories to be excluded from deployment, such as tests

#### `.distignore`

**Notes:** `.distignore` is for files to be ignored **only**; it does not currently allow negation like `.gitignore`. This comes from its current expected syntax in WP-CLI's [`wp dist-archive` command](https://github.com/wp-cli/dist-archive-command/). It is possible that this Action will allow for includes via something like a `.distinclude` file in the future, or that WP-CLI itself makes a change that this Action will reflect for consistency. It also will need to contain more than `.gitattributes` because that method **also** respects `.gitignore`.
**Notes:** `.distignore` supports the full `.gitignore` syntax which allows negations such as `!important.txt`. This functionality comes from the WP-CLI's [`wp dist-archive` command](https://github.com/wp-cli/dist-archive-command/).

```
/.wordpress-org
Expand Down
27 changes: 26 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,34 @@ if [[ "$BUILD_DIR" = false ]]; then
echo "➤ Copying files..."
if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
echo "ℹ︎ Using .distignore"

# Deleting the git data so that the repo is reinitialized
rm -rf "$GITHUB_WORKSPACE/.git"

# Removing the existing .gitignore file to replace it with the .distignore file
rm "$GITHUB_WORKSPACE/.gitignore"

# Renaming the .distignore file to .gitignore
cp "$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/.gitignore"

cd "$GITHUB_WORKSPACE"

# Initializing the git repo for the new .gitignore file to be taken into account
git init

git add . > /dev/null 2>&1

# Get the list files to be copied into a txt file.
git ls-files > included-files.txt

# Return to the SVN dir.
cd "$SVN_DIR"

# Copy from current branch to /trunk, excluding dotorg assets
# The --files-from flag will only copy files from the included files list
# 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
# The --itemize-changes flag will show the changes made to each file
rsync -rcv --files-from="$GITHUB_WORKSPACE/included-files.txt" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes
else
echo "ℹ︎ Using .gitattributes"

Expand Down