mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-18 06:10:30 +02:00
feat: allow action to use current commit instead of creating a new one
This commit is contained in:
@@ -20,10 +20,13 @@ A GitHub action for styling files with [prettier](https://prettier.io).
|
|||||||
| prettier_version | :x: | False | Specific prettier version (by default use latest) |
|
| prettier_version | :x: | False | Specific prettier version (by default use latest) |
|
||||||
| 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) |
|
||||||
| commit_options | :x: | - | Custom git commit options |
|
| commit_options | :x: | - | Custom git commit options |
|
||||||
|
| same_commit | :x: | False | Whether to merge into the current commit instead of creating a new one |
|
||||||
| commit_message | :x: | Prettified Code! | Custom git commit message |
|
| commit_message | :x: | Prettified Code! | Custom git commit message |
|
||||||
| file_pattern | :x: | * | Custom git add file pattern |
|
| file_pattern | :x: | * | Custom git add file pattern |
|
||||||
| branch (depreciated with 3.0)| :white_check_mark: | - | Always set this to `${{ github.head_ref }}` in order to work both with pull requests and push events |
|
| branch (depreciated with 3.0)| :white_check_mark: | - | Always set this to `${{ github.head_ref }}` in order to work both with pull requests and push events |
|
||||||
|
|
||||||
|
> Note: using the same_commit option may lead to problems if other actions are relying on the commit being the same before and after the prettier action has ran. Keep this in mind.
|
||||||
|
|
||||||
### Example Config
|
### Example Config
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ inputs:
|
|||||||
description: Commit message
|
description: Commit message
|
||||||
required: false
|
required: false
|
||||||
default: 'Prettified Code!'
|
default: 'Prettified Code!'
|
||||||
|
same_commit:
|
||||||
|
description: Whether to use the current commit instead of creating a new one
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
commit_options:
|
commit_options:
|
||||||
description: Commit options
|
description: Commit options
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -53,7 +53,12 @@ then
|
|||||||
# Add changes to git
|
# Add changes to git
|
||||||
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}"
|
||||||
# Commit and push changes back
|
# Commit and push changes back
|
||||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
if $INPUT_SAME_COMMIT; then
|
||||||
|
echo "Amending the current commit..."
|
||||||
|
git commit --amend --no-edit
|
||||||
|
else
|
||||||
|
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
||||||
|
fi
|
||||||
git push origin
|
git push origin
|
||||||
echo "Changes pushed successfully."
|
echo "Changes pushed successfully."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user