From b94afd2dd007daf54caea5e096b2e9c3687c6325 Mon Sep 17 00:00:00 2001 From: Conrad Date: Wed, 18 Mar 2020 14:31:39 +0100 Subject: [PATCH] Added custom folder option --- README.md | 1 + action.yml | 4 ++++ entrypoint.sh | 7 ++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c7eb090..6d08f1f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ GitHub action for automatic lossless image compression using OptiPNG for PNG com | commit_message | :x: | Prettified Code! | Custom git commit message | | file_pattern | :x: | * | Custom git add file pattern | | branch | :white_check_mark: | - | There are two types of action triggers in GitHub: on pull request and on push. The branch needs to be defined for both, but in case of the pull request trigger it should have `${{ github.head_ref }}` and on push it should have the branch the trigger is designed for. | +| folder | :x: | . | Custom search folder, if you don't want to search the whole repository. | ### Example Config diff --git a/action.yml b/action.yml index 99f620f..2e896d5 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,10 @@ inputs: branch: description: Target branch for the changes required: true + folder: + description: Starting folder for recursive search + required: false + default: '.' runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index e15ec8f..7320d95 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -36,9 +36,10 @@ _git_push() { } # PROGRAM -find . -type f -name "*.jpg" -exec jpegoptim {} \; -find . -type f -name "*.jpeg" -exec jpegoptim {} \; -find . -type f -name "*.png" -exec optipng -nc -nb -o7 {} \; +find $INPUT_FOLDER -type f -name "*.jpg" -exec jpegoptim {} \; +find $INPUT_FOLDER -type f -name "*.jpeg" -exec jpegoptim {} \; +# nc nb are so that no color information is lost +find $INPUT_FOLDER -type f -name "*.png" -exec optipng -nc -nb -o7 {} \; # To keep runtime good, just continue if something was changed if _git_changed;