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

Add option to ignore changes to the vendor directory #54

Closed
wants to merge 3 commits into from
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 @@ -29,6 +29,7 @@ Because the WordPress.org plugin repository shows information from the readme in
* `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`). If you want to skip updating assets because you don't have an assets directory, set `SKIP_ASSETS : true`
* `README_NAME` - defaults to `readme.txt`, customizable in case you use `README.md` instead, which is now quietly supported in the WordPress.org plugin repository.
* `IGNORE_OTHER_FILES` - defaults to `false`, which means that all your files are copied (as in [WordPress.org Plugin Deploy Action](https://github.com/10up/action-wordpress-plugin-deploy), respecting `.distignore` and `.gitattributes`), and the Action will bail if anything except assets and `readme.txt` are modified. See "Important note" above. If you set this variable to `true`, then only assets and `readme.txt` will be copied, and changes to other files will be ignored and not committed.
* `IGNORE_VENDOR_DIR` - defaults to `false`. If you want to ignore any changes made in the `vendor` directory, set this to `true`. For example, if you have production dependencies that are managed by Composer, you'll often run into issues where the contents of the `vendor` directory are modified during the build process and this Action will bail because of those changes. Setting this to `true` will revert those changes before committing to the svn repo.

## Example Git Workflow

Expand Down
15 changes: 13 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ if [[ -z "$IGNORE_OTHER_FILES" ]]; then
fi
echo "ℹ︎ IGNORE_OTHER_FILES is $IGNORE_OTHER_FILES"

if [[ -z "$IGNORE_VENDOR_DIR" ]]; then
IGNORE_VENDOR_DIR=false
fi
echo "ℹ︎ IGNORE_VENDOR_DIR is $IGNORE_VENDOR_DIR"

SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/"
SVN_DIR="${HOME}/svn-${SLUG}"

Expand All @@ -53,7 +58,7 @@ svn update --set-depth infinity trunk
echo "➤ Copying files..."
if [ "$IGNORE_OTHER_FILES" = true ]; then
# Copy readme.txt to /trunk
cp "$GITHUB_WORKSPACE/$README_NAME" trunk/$README_NAME
cp "$GITHUB_WORKSPACE/$README_NAME" "trunk/$README_NAME"

# Use $TMP_DIR as the source of truth
TMP_DIR=$GITHUB_WORKSPACE
Expand Down Expand Up @@ -127,6 +132,12 @@ fi

echo "➤ Preparing files..."

# If we want to ignore changes in the vendor directory, revert those back
if [[ "$IGNORE_VENDOR_DIR" == "true" ]] && svn stat trunk | grep -qi -e " trunk/vendor$" -e " trunk/vendor/"; then
echo "ℹ︎ Reverting changes in vendor directory"
svn revert --depth=infinity trunk/vendor
fi

svn status

if [[ -z $(svn stat) ]]; then
Expand Down Expand Up @@ -168,7 +179,7 @@ svn add . --force > /dev/null
# Also suppress stdout here
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm %@ > /dev/null

#Resolves => SVN commit failed: Directory out of date
# Resolves => SVN commit failed: Directory out of date
svn update

# Now show full SVN status
Expand Down
Loading