|
1 | | -# prettierc-cli-action |
| 1 | +# Prettier CLI Check |
| 2 | + |
| 3 | +A GitHub action to run [Prettier](https://prettier.io/) CLI Checks. This project was **heavily** inspired by other actions available and a shoutout to [@creyD](https://github.com/creyD). The goal of this project was to create a simple action which would be easy to use. |
| 4 | + |
| 5 | +[![Code Style][code-style-shield]][code-style-url] |
| 6 | +[![Latest Release][release-shield]][release-url] |
| 7 | +[![MIT License][license-shield]][license-url] |
| 8 | +[![Issues][issues-shield]][issues-url] |
| 9 | +[![Contributors][contributors-shield]][contributors-url] |
| 10 | +[![Forks][forks-shield]][forks-url] |
| 11 | +[![Stargazers][stars-shield]][stars-url] |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +### Parameters |
| 16 | + |
| 17 | +| Parameter | Default | Description | |
| 18 | +| ---------------- | :-------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 19 | +| file_pattern | `'**/*.js'` | The file pattern prettier will check. Follow [glob syntax](https://github.com/mrmlnc/fast-glob#pattern-syntax). | |
| 20 | +| config_path | `''` | The path to the `prettierrc` file. Read more [here](https://prettier.io/docs/en/configuration.html). | |
| 21 | +| ignore_path | `'./.prettierignore'` | The path to the `prettierignore` file. This file should list file patterns to skip using the [glob syntax](https://github.com/mrmlnc/fast-glob#pattern-syntax). | |
| 22 | +| prettier_version | `'latest'` | The version of prettier to use. Find versions [here](https://www.npmjs.com/package/prettier?activeTab=versions). | |
| 23 | +| fail_on_error | `true` | Whether the action should fail if prettier finds errors in formatting. | |
| 24 | + |
| 25 | +### Output |
| 26 | + |
| 27 | +You can access the list of files prettier found errors using the actions context like `steps.<step-id>.outputs.prettier_output`. The returned value is a list of files as a string, one per line. |
| 28 | + |
| 29 | +### Examples |
| 30 | + |
| 31 | +```yaml |
| 32 | +name: Continuous Integration |
| 33 | + |
| 34 | +# This action works with pull requests and pushes on the main branch |
| 35 | +on: |
| 36 | + pull_request: |
| 37 | + push: |
| 38 | + branches: [main] |
| 39 | + |
| 40 | +jobs: |
| 41 | + prettier: |
| 42 | + name: Prettier Check |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Checkout Repository |
| 46 | + uses: actions/checkout@v2 |
| 47 | + |
| 48 | + - name: Run Prettier |
| 49 | + id: prettier-run |
| 50 | + uses: rutajdash/prettier-cli-action@add69d989fe32136a4ee5f6f9026ae830bbc21b8 |
| 51 | + with: |
| 52 | + config_path: ./.prettierrc.yml |
| 53 | + |
| 54 | + # This step only runs if prettier finds errors causing the previous step to fail |
| 55 | + # This steps lists the files where errors were found |
| 56 | + - name: Prettier Output |
| 57 | + if: ${{ failure() }} |
| 58 | + shell: bash |
| 59 | + run: | |
| 60 | + echo "The following files are not formatted:" |
| 61 | + echo "${{steps.prettier-run.outputs.prettier_output}}" |
| 62 | +``` |
| 63 | +
|
| 64 | +More documentation for writing a workflow can be found [here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions). |
| 65 | +
|
| 66 | +## Issues |
| 67 | +
|
| 68 | +Please report all bugs and feature requests using the [GitHub issues function](https://github.com/rutajdash/prettier-cli-action/issues/new/choose). Thanks! |
| 69 | +
|
| 70 | +## Contributing |
| 71 | +
|
| 72 | +Pull Requests are always welcome! Feel free to pick any [issue][issues-url] or raise a new [feature request][feature-request-url]! |
| 73 | +Do read the [contributing guidelines][contributing-guidelines-url] and [code of conduct][code-of-conduct-url]. |
| 74 | +
|
| 75 | +[code-style-shield]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=plastic |
| 76 | +[code-style-url]: https://github.com/prettier/prettier |
| 77 | +[release-shield]: https://img.shields.io/github/v/release/rutajdash/prettier-cli-action?style=plastic |
| 78 | +[release-url]: https://github.com/rutajdash/prettier-cli-actions/releases |
| 79 | +[contributors-shield]: https://img.shields.io/github/contributors/rutajdash/prettier-cli-action?style=plastic |
| 80 | +[contributors-url]: https://github.com/rutajdash/prettier-cli-action/graphs/contributors |
| 81 | +[forks-shield]: https://img.shields.io/github/forks/rutajdash/prettier-cli-action?style=plastic |
| 82 | +[forks-url]: https://github.com/rutajdash/prettier-cli-action/network/members |
| 83 | +[stars-shield]: https://img.shields.io/github/stars/rutajdash/prettier-cli-action?style=plastic |
| 84 | +[stars-url]: https://github.com/rutajdash/prettier-cli-action/stargazers |
| 85 | +[issues-shield]: https://img.shields.io/github/issues/rutajdash/prettier-cli-action?style=plastic |
| 86 | +[issues-url]: https://github.com/rutajdash/prettier-cli-action/issues |
| 87 | +[feature-request-url]: https://github.com/rutajdash/prettier-cli-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=feat%3A |
| 88 | +[license-shield]: https://img.shields.io/github/license/rutajdash/prettier-cli-action?style=plastic |
| 89 | +[license-url]: https://github.com/rutajdash/prettier-cli-action/blob/main/LICENSE |
| 90 | +[contributing-guidelines-url]: https://github.com/rutajdash/prettier-cli-action/blob/main/CONTRIBUTING.md |
| 91 | +[code-of-conduct-url]: https://github.com/rutajdash/prettier-cli-action/blob/main/CODE_OF_CONDUCT.md |
0 commit comments