Skip to content

Commit 5e54c68

Browse files
authored
Merge pull request #143 from creyD/dev
Fixed a bug with ONLY_CHANGED_PR and added ALLOW_OTHER_PLUGINS
2 parents d7f059e + ff6bab6 commit 5e54c68

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ A GitHub action for styling files with [prettier](https://prettier.io).
3131
| only_changed | :x: | `false` | Only prettify changed files, can't be used with file_pattern! This command works only with the checkout action set to fetch depth '0' (see example 2)|
3232
| github_token | :x: | `${{ github.token }}` | The default [GITHUB_TOKEN](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret) or a [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token)
3333
| git_identity | :x: | `actions` | Set to `author` to use author's user as committer. This allows triggering [further workflow runs](https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs)
34+
| allow_other_plugins | :x: | `false` | Allow other plugins to be installed (prevents the @prettier-XYZ regex check) |
3435

3536
> 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.
3637

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ inputs:
7070
description: Which identity is used for git name/email when committing changes. Needs to be one of "actions" or "author".
7171
required: false
7272
default: "actions"
73+
allow_other_plugins:
74+
description: Allow other plugins to be installed. By default, we are checking if the plugins are actually prettier plugins.
75+
required: false
76+
default: false
7377

7478
runs:
7579
using: "composite"
@@ -97,6 +101,7 @@ runs:
97101
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
98102
INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }}
99103
INPUT_GIT_IDENTITY: ${{ inputs.git_identity }}
104+
INPUT_ALLOW_OTHER_PLUGINS: ${{ inputs.allow_other_plugins }}
100105

101106
branding:
102107
icon: "award"

entrypoint.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ npm install --silent prettier@$INPUT_PRETTIER_VERSION
4949

5050
# Install plugins
5151
if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then
52-
for plugin in $INPUT_PRETTIER_PLUGINS; do
53-
echo "Checking plugin: $plugin"
54-
# check regex against @prettier/xyz
55-
if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then
56-
echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting."
57-
exit 1
58-
fi
59-
done
52+
if [ "$INPUT_ALLOW_OTHER_PLUGINS" != "true" ]; then
53+
for plugin in $INPUT_PRETTIER_PLUGINS; do
54+
echo "Checking plugin: $plugin"
55+
# check regex against @prettier/xyz
56+
if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then
57+
echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting."
58+
exit 1
59+
fi
60+
done
61+
fi
6062
npm install --silent $INPUT_PRETTIER_PLUGINS
6163
fi
6264
)
@@ -87,7 +89,7 @@ fi
8789

8890
# If running under only_changed, reset every modified file that wasn't also modified in the last commit
8991
# This allows only_changed and dry to work together, and simplified the non-dry logic below
90-
if [ $INPUT_ONLY_CHANGED = true ] || [$INPUT_ONLY_CHANGED_PR = true ] ; then
92+
if [ $INPUT_ONLY_CHANGED = true ] || [ $INPUT_ONLY_CHANGED_PR = true ] ; then
9193
BASE_BRANCH=origin/$GITHUB_BASE_REF
9294
if $INPUT_ONLY_CHANGED; then
9395
BASE_BRANCH=HEAD~1

0 commit comments

Comments
 (0)