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

Fix 80 #2

Merged
merged 3 commits into from
Jun 28, 2023
Merged
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 @@ -16,6 +16,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
| Parameter | Required | Default | Description |
| - | :-: | :-: | - |
| dry | :x: | `false` | Runs the action in dry mode. Files wont get changed and the action fails if there are unprettified files. Recommended to use with prettier_options --check |
| dry_no_fail | :x: | `false` | Don't exit the process in case of changes. This allows the commit and push to a repo to be handled by a follow up step |
| prettier_version | :x: | `false` | Specific prettier version (by default use latest) |
| working_directory | :x: | `false` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` |
| prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) |
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ inputs:
description: Running the script in dry mode just shows whether there are files that should be prettified or not
required: false
default: false
dry_no_fail:
description: Dry mode do not exit the process in case of changes (so that other follow up actions can take care of commits)
required: false
default: false
prettier_version:
description: Specific version of prettier (by default just use the latest version)
required: false
Expand Down Expand Up @@ -75,6 +79,7 @@ runs:
INPUT_FILE_PATTERN: ${{ inputs.file_pattern }}
INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }}
INPUT_DRY: ${{ inputs.dry }}
INPUT_DRY_NO_FAIL: ${{ inputs.dry_no_fail }}
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
Expand Down
8 changes: 6 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@ if _git_changed; then
if $INPUT_DRY; then
echo "Unpretty Files Changes:"
_git_changes
echo "Finishing dry-run. Exiting before committing."
exit 1
if INPUT_DRY_NO_FAIL; then
echo "There are chaanges that won't be commited, you can use an external job to do so".
else
echo "Finishing dry-run. Exiting before committing."
exit 1
fi
else
# Calling method to configure the git environemnt
_git_setup
Expand Down