From e2704493afdf1f5ae9ced0208435652e3325df9a Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 13:20:52 +0200 Subject: [PATCH 1/3] feat: #98 added option to allow for other plugins --- action.yml | 5 +++++ entrypoint.sh | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 54dbc65..5072dcd 100644 --- a/action.yml +++ b/action.yml @@ -70,6 +70,10 @@ inputs: description: Which identity is used for git name/email when committing changes. Needs to be one of "actions" or "author". required: false default: "actions" + allow_other_plugins: + description: Allow other plugins to be installed. By default, we are checking if the plugins are actually prettier plugins. + required: false + default: false runs: using: "composite" @@ -97,6 +101,7 @@ runs: INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} INPUT_CLEAN_NODE_FOLDER: ${{ inputs.clean_node_folder }} INPUT_GIT_IDENTITY: ${{ inputs.git_identity }} + INPUT_ALLOW_OTHER_PLUGINS: ${{ inputs.allow_other_plugins }} branding: icon: "award" diff --git a/entrypoint.sh b/entrypoint.sh index 7ba5200..d23f779 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -49,14 +49,16 @@ npm install --silent prettier@$INPUT_PRETTIER_VERSION # Install plugins if [ -n "$INPUT_PRETTIER_PLUGINS" ]; then - for plugin in $INPUT_PRETTIER_PLUGINS; do - echo "Checking plugin: $plugin" - # check regex against @prettier/xyz - if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then - echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting." - exit 1 - fi - done + if [ "$INPUT_ALLOW_OTHER_PLUGINS" != "true" ]; then + for plugin in $INPUT_PRETTIER_PLUGINS; do + echo "Checking plugin: $plugin" + # check regex against @prettier/xyz + if ! echo "$plugin" | grep -Eq '(@prettier\/plugin-|(@[a-z\-]+\/)?prettier-plugin-){1}([a-z\-]+)'; then + echo "$plugin does not seem to be a valid @prettier/plugin-x plugin. Exiting." + exit 1 + fi + done + fi npm install --silent $INPUT_PRETTIER_PLUGINS fi ) From 22eb0287662667fc9dfa3fe439c098046fe979e9 Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 13:26:14 +0200 Subject: [PATCH 2/3] fix: updated docs for action --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0b1032a..0aa63a4 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ A GitHub action for styling files with [prettier](https://prettier.io). | 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)| | 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) | 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) +| allow_other_plugins | :x: | `false` | Allow other plugins to be installed (prevents the @prettier-XYZ regex check) | > 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. From ff6bab60304c6a55de0aa3f8d342f0aefbb2ab8c Mon Sep 17 00:00:00 2001 From: Conrad Date: Thu, 8 May 2025 13:28:44 +0200 Subject: [PATCH 3/3] fix: fixed a bug with INPUT_ONLY_CHANGED_PR --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index d23f779..7c8f4bf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -89,7 +89,7 @@ fi # If running under only_changed, reset every modified file that wasn't also modified in the last commit # This allows only_changed and dry to work together, and simplified the non-dry logic below -if [ $INPUT_ONLY_CHANGED = true ] || [$INPUT_ONLY_CHANGED_PR = true ] ; then +if [ $INPUT_ONLY_CHANGED = true ] || [ $INPUT_ONLY_CHANGED_PR = true ] ; then BASE_BRANCH=origin/$GITHUB_BASE_REF if $INPUT_ONLY_CHANGED; then BASE_BRANCH=HEAD~1