Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace --exclude-from with --filter to allow for .gitignore syntax in .distignore #148

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
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
6 changes: 4 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ if [[ "$BUILD_DIR" = false ]]; then
if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
echo "ℹ︎ Using .distignore"
# Copy from current branch to /trunk, excluding dotorg assets
# The --filter flag will allow the full .gitignore syntax to be used in .distignore
# 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 --filter="merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes
else
echo "ℹ︎ Using .gitattributes"

Expand All @@ -114,7 +116,7 @@ if [[ "$BUILD_DIR" = false ]]; then
git config --global user.name "10upbot on GitHub"

# Ensure git archive will pick up any changed files in the directory try.
test $(git ls-files --deleted) && git rm $(git ls-files --deleted)
test "$(git ls-files --deleted)" && git rm "$(git ls-files --deleted)"
if [ -n "$(git status --porcelain --untracked-files=all)" ]; then
git add .
git commit -m "Include build step changes"
Expand Down