Skip to content

Commit

Permalink
Added working_directory parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
creyD committed Nov 30, 2021
1 parent b1dc9cd commit 8efb5a8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
| - | :-: | :-: | - |
| 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 |
| 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 |
| prettier_options | :x: | `"--write **/*.js"` | Prettier options (by default it applies to the whole repository) |
| commit_options | :x: | - | Custom git commit options |
| push_options | :x: | - | Custom git push options |
Expand Down
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,23 @@ inputs:
description: Specific version of prettier (by default just use the latest version)
required: false
default: false
working_directory:
description: Specify a directory to cd into before installing prettier and running it
required: false
default: false
only_changed:
description: Only prettify files changed in the last commit, can't be used with file_pattern!
required: false
default: false
prettier_plugins:
description: Install Prettier plugins, i.e. `@prettier/plugin-php @prettier/plugin-other`
required: false
default: ''
default: ""
github_token:
description: GitHub Token or PAT token used to authenticate against a repository
required: false
default: ${{ github.token }}


runs:
using: "composite"
steps:
Expand All @@ -71,6 +74,7 @@ runs:
INPUT_PRETTIER_VERSION: ${{ inputs.prettier_version }}
INPUT_ONLY_CHANGED: ${{ inputs.only_changed }}
INPUT_PRETTIER_PLUGINS: ${{ inputs.prettier_plugins }}
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}

branding:
Expand Down
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ cd "$GITHUB_ACTION_PATH"

echo "Installing prettier..."

case $INPUT_WORKING_DIRECTORY in
false)
;;
*)
cd $INPUT_WORKING_DIRECTORY
;;
esac

case $INPUT_PRETTIER_VERSION in
false)
npm install --silent prettier
Expand Down

0 comments on commit 8efb5a8

Please sign in to comment.