From 4c95c0c5d0c0a8dcb020c82c84a419c75bbdeaa5 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Wed, 3 Apr 2024 11:42:15 -0500 Subject: [PATCH 01/14] Replace --exclude-from with --filter to allow for .gitignore syntax in .distignore --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 50af5f6..fd70da2 100755 --- a/deploy.sh +++ b/deploy.sh @@ -94,8 +94,9 @@ 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 + rsync -rc --filter="merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded else echo "ℹ︎ Using .gitattributes" From 225bc5391ec3e85198e637ea1b3baf465c30d6f1 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Wed, 3 Apr 2024 12:24:42 -0500 Subject: [PATCH 02/14] Update README to show that full syntax is supported --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5170895..54852c8 100644 --- a/README.md +++ b/README.md @@ -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 From 64424d6b65614a78adabd89e3b3318df97d406b0 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Wed, 14 Aug 2024 09:31:31 -0500 Subject: [PATCH 03/14] Change syntax to dir-merge to see if direcotires are supported in the distignore file --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index fd70da2..960e41c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -96,7 +96,7 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded + rsync -rc --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded else echo "ℹ︎ Using .gitattributes" From dd8d664e34a5b50fae9543b14436eca81676a152 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Wed, 14 Aug 2024 09:41:43 -0500 Subject: [PATCH 04/14] Wrap command in quotes to pass static analysis --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 960e41c..a4df93a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -115,7 +115,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" From aaec0a2090dd18d52081906be5889e7cdb24bab4 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 07:40:44 -0500 Subject: [PATCH 05/14] add logging to rsync command --- deploy.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index a4df93a..50403ec 100755 --- a/deploy.sh +++ b/deploy.sh @@ -96,7 +96,8 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded + # rsync -rc --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded + rsync -rcv --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes else echo "ℹ︎ Using .gitattributes" From d14eb773fa0157501c3bd61412b24381096cd219 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 07:54:22 -0500 Subject: [PATCH 06/14] change rsync command --- deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 50403ec..441a489 100755 --- a/deploy.sh +++ b/deploy.sh @@ -93,11 +93,13 @@ if [[ "$BUILD_DIR" = false ]]; then echo "➤ Copying files..." if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then echo "ℹ︎ Using .distignore" + ls -la $GITHUB_WORKSPACE/readme.txt + rsync --version # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - rsync -rcv --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes + rsync -rcv --filter="merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes else echo "ℹ︎ Using .gitattributes" From 488a537d9b5c3fa77acb801194e1c5eb5f98827d Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 07:57:29 -0500 Subject: [PATCH 07/14] dir merge --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index 441a489..d8267dd 100755 --- a/deploy.sh +++ b/deploy.sh @@ -99,7 +99,7 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - rsync -rcv --filter="merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes + rsync -rcv --filter="dir-merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes else echo "ℹ︎ Using .gitattributes" From 7416faa1e064fb0f9c6ed2fda906cebcbbe8a483 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 07:57:49 -0500 Subject: [PATCH 08/14] remove some logging --- deploy.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index d8267dd..e13b5a7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -93,7 +93,6 @@ if [[ "$BUILD_DIR" = false ]]; then echo "➤ Copying files..." if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then echo "ℹ︎ Using .distignore" - ls -la $GITHUB_WORKSPACE/readme.txt rsync --version # Copy from current branch to /trunk, excluding dotorg assets # The --filter flag will allow the full .gitignore syntax to be used in .distignore From d52cd6dc07a5ef347a056ecd58df75464eafc650 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 08:04:36 -0500 Subject: [PATCH 09/14] process file --- deploy.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index e13b5a7..08123b1 100755 --- a/deploy.sh +++ b/deploy.sh @@ -98,7 +98,9 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - rsync -rcv --filter="dir-merge $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded --itemize-changes + sed 's/^/- /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^- !/+ /' > tmp_rules && \ + rsync -rc --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete && \ + rm tmp_rules else echo "ℹ︎ Using .gitattributes" From 3509cb4a6ffa594a3b6e1e56ea37bd256d18f9f6 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 08:34:13 -0500 Subject: [PATCH 10/14] process file again --- deploy.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 08123b1..d20024c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -98,9 +98,9 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - sed 's/^/- /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^- !/+ /' > tmp_rules && \ - rsync -rc --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete && \ - rm tmp_rules + sed 's/^!/+ /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^[^+]/- /' > tmp_rules && \ + rsync -rcv --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ + rm tmp_rules else echo "ℹ︎ Using .gitattributes" From 26675c13f30927d0d6445ca57a68e9c54b6618d0 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 09:49:17 -0500 Subject: [PATCH 11/14] merge plus exclusions --- deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index d20024c..eead688 100755 --- a/deploy.sh +++ b/deploy.sh @@ -99,7 +99,7 @@ if [[ "$BUILD_DIR" = false ]]; then # The --delete flag will delete anything in destination that no longer exists in source # rsync -rc --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded sed 's/^!/+ /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^[^+]/- /' > tmp_rules && \ - rsync -rcv --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ + rsync -rcv --filter="merge,- tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ rm tmp_rules else echo "ℹ︎ Using .gitattributes" From a646a35e6394ff46a968537805c1c577c41712e1 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 10:05:27 -0500 Subject: [PATCH 12/14] merge plus exclusions --- deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index eead688..0d8a0d7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -97,10 +97,10 @@ if [[ "$BUILD_DIR" = false ]]; then # 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 --filter="dir-merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded - sed 's/^!/+ /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^[^+]/- /' > tmp_rules && \ - rsync -rcv --filter="merge,- tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ - rm tmp_rules + rsync -rcv --filter="merge,- $GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes + # sed 's/^!/+ /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^[^+]/- /' > tmp_rules && \ + # rsync -rcv --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ + # rm tmp_rules else echo "ℹ︎ Using .gitattributes" From 739c0622552907b728a7b0c8ec79dc1c83f193e6 Mon Sep 17 00:00:00 2001 From: Clayton Collie Date: Mon, 16 Sep 2024 10:08:14 -0500 Subject: [PATCH 13/14] clean up --- deploy.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/deploy.sh b/deploy.sh index 0d8a0d7..29280e8 100755 --- a/deploy.sh +++ b/deploy.sh @@ -93,14 +93,11 @@ if [[ "$BUILD_DIR" = false ]]; then echo "➤ Copying files..." if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then echo "ℹ︎ Using .distignore" - rsync --version # 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 + # 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 - # sed 's/^!/+ /' "$GITHUB_WORKSPACE/.distignore" | sed 's/^[^+]/- /' > tmp_rules && \ - # rsync -rcv --filter="merge tmp_rules" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes && \ - # rm tmp_rules else echo "ℹ︎ Using .gitattributes" From f0209882f89ca8853016e58f0bbb3c7077c4a0b6 Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Thu, 29 May 2025 02:31:54 +0300 Subject: [PATCH 14/14] Alternative approach --- deploy.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/deploy.sh b/deploy.sh index 6111059..a6c1f6d 100755 --- a/deploy.sh +++ b/deploy.sh @@ -130,11 +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 --filter flag will allow the full .gitignore syntax to be used in .distignore + # 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 # 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 + rsync -rcv --files-from="$GITHUB_WORKSPACE/included-files.txt" "$GITHUB_WORKSPACE/" trunk/ --delete --itemize-changes else echo "ℹ︎ Using .gitattributes"