Added custom folder option

This commit is contained in:
2020-03-18 14:31:39 +01:00
parent 20dc277145
commit b94afd2dd0
3 changed files with 9 additions and 3 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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;