mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-16 21:30:31 +02:00
Support not exiting the process in case of changes in dry mode (#122)
Co-authored-by: Conrad <grosserconrad@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9aba96f268
commit
4bd40fc486
@@ -16,6 +16,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
|
|||||||
| Parameter | Required | Default | Description |
|
| 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 | :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 |
|
||||||
|
| no_commit | :x: | `false` | Can be used to avoid committing the changes (useful when another workflow step commits after this one anyways; can be combined with dry mode) |
|
||||||
| prettier_version | :x: | `latest` | Specific prettier version (by default use latest) |
|
| prettier_version | :x: | `latest` | Specific prettier version (by default use latest) |
|
||||||
| working_directory | :x: | `${{ github.action_path }}` | Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example `app/` |
|
| working_directory | :x: | `${{ github.action_path }}` | 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) |
|
| prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) |
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ inputs:
|
|||||||
description: Running the script in dry mode just shows whether there are files that should be prettified or not
|
description: Running the script in dry mode just shows whether there are files that should be prettified or not
|
||||||
required: false
|
required: false
|
||||||
default: false
|
default: false
|
||||||
|
no_commit:
|
||||||
|
description: Can be used to avoid committing the changes (can be combined with dry mode, useful when another workflow steps commits after this commit anyways)
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
prettier_version:
|
prettier_version:
|
||||||
description: Specific version of prettier (by default just use the latest version)
|
description: Specific version of prettier (by default just use the latest version)
|
||||||
required: false
|
required: false
|
||||||
@@ -76,6 +80,7 @@ runs:
|
|||||||
INPUT_FILE_PATTERN: ${{ inputs.file_pattern }}
|
INPUT_FILE_PATTERN: ${{ inputs.file_pattern }}
|
||||||
INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }}
|
INPUT_PRETTIER_OPTIONS: ${{ inputs.prettier_options }}
|
||||||
INPUT_DRY: ${{ inputs.dry }}
|
INPUT_DRY: ${{ inputs.dry }}
|
||||||
|
INPUT_DRY_NO_COMMIT: ${{ inputs.no_commit }}
|
||||||
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
|
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
|
||||||
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
|
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
|
||||||
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
|
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
|
||||||
|
|||||||
@@ -79,8 +79,12 @@ if _git_changed; then
|
|||||||
if $INPUT_DRY; then
|
if $INPUT_DRY; then
|
||||||
echo "Unpretty Files Changes:"
|
echo "Unpretty Files Changes:"
|
||||||
git diff
|
git diff
|
||||||
echo "Finishing dry-run. Exiting before committing."
|
if $INPUT_NO_COMMIT; then
|
||||||
exit 1
|
echo "There are changes 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
|
else
|
||||||
# Calling method to configure the git environemnt
|
# Calling method to configure the git environemnt
|
||||||
_git_setup
|
_git_setup
|
||||||
@@ -99,6 +103,11 @@ if _git_changed; then
|
|||||||
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
|
git add "${INPUT_FILE_PATTERN}" || echo "Problem adding your files with pattern ${INPUT_FILE_PATTERN}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $INPUT_NO_COMMIT; then
|
||||||
|
echo "There are changes that won't be commited, you can use an external job to do so."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Commit and push changes back
|
# Commit and push changes back
|
||||||
if $INPUT_SAME_COMMIT; then
|
if $INPUT_SAME_COMMIT; then
|
||||||
echo "Amending the current commit..."
|
echo "Amending the current commit..."
|
||||||
|
|||||||
Reference in New Issue
Block a user