mirror of
https://github.com/creyD/prettier_action.git
synced 2026-04-12 19:30:30 +02:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a3b4af5f5b | |||
| 0b7dd998bb | |||
| 554e56f267 | |||
| f18a80caf3 | |||
| cbf12d08d5 | |||
| 7524f50124 | |||
| e1f9dea8d5 | |||
| 43b949365d | |||
| d2b9447220 | |||
| 01d985bf80 | |||
| 073765dcfc | |||
| ce8fd0f388 | |||
| 90fb642c22 | |||
| 610abaf402 | |||
| a7de566991 | |||
| 07dc95a6c7 | |||
| 25777abf08 | |||
| 0865129567 |
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a problem!
|
||||
title: "[BUG]"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**What exactly happened?**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**What should've happened?**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**How did it look?**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Where did you encounter the problem?**
|
||||
- OS: [e.g. iOS]
|
||||
- Repo: [e.g. URL to your repository]
|
||||
- Version [e.g. 22]
|
||||
|
||||
<!-- If you think you can help us with that, please note it here! -->
|
||||
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
16
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Request a feature!
|
||||
title: "[FEATURE]"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**What would you like to change about the program?**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Why do you think this is a cool idea?**
|
||||
A clear and concise description of why your feature would improve the program.
|
||||
|
||||
<!-- If you think you can help us with that, please note it here! -->
|
||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# MacOS system files
|
||||
.DS_Store
|
||||
# NPM
|
||||
node_modules/
|
||||
41
README.md
41
README.md
@@ -1,19 +1,48 @@
|
||||
# GitHub Prettier Action
|
||||
|
||||
A GitHub action for styling files with [prettier](prettier.io).
|
||||
A GitHub action for styling files with [prettier](https://prettier.io).
|
||||
|
||||
## Usage
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Required | Default | Description |
|
||||
| - | - | - | - |
|
||||
| prettier_options | :white_check_mark: | - | Prettier options |
|
||||
| commit_options | :x: | - | Custom git commit options |
|
||||
| commit_message | :x: | 'Prettified Code!' | Custom git commit message |
|
||||
| file_pattern | :x: | '*' | Custom git add file pattern |
|
||||
| - | :-: | :-: | - |
|
||||
| prettier_options | :x: | --write **/*.js | Prettier options (by default it applies to the whole repository) |
|
||||
| commit_options | :x: | No options. | Custom git commit options |
|
||||
| commit_message | :x: | Prettified Code! | Custom git commit message |
|
||||
| file_pattern | :x: | * | Custom git add file pattern |
|
||||
| branch | :white_check_mark: | - | Custom git publish branch, use ${{ github.head_ref }} if used in pull requests |
|
||||
|
||||
### Example Config
|
||||
|
||||
This is a small example of what your `action.yml` could look like:
|
||||
|
||||
```yaml
|
||||
name: Prettier for JS Code
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
cleanup_tasks:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Cloning the repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: Prettify the JS Code
|
||||
uses: creyD/prettier_action@v1.0
|
||||
with:
|
||||
prettier_options: '--no-semi --write src/**/*.js'
|
||||
branch: ${{ github.head_ref }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
This simple example executes `prettier --no-semi --write src/**/*.js` after someone created a Pull Request on your repository. More documentation can be found [here](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions).
|
||||
|
||||
## Issues
|
||||
|
||||
Please report all bugs and feature request using the [GitHub issues function](https://github.com/creyD/prettier_action/issues/new).
|
||||
|
||||
19
action.yml
19
action.yml
@@ -1,5 +1,5 @@
|
||||
name: 'Prettier Action'
|
||||
description: 'Automatically runs prettier on all your pull requests.'
|
||||
name: "Prettier Action"
|
||||
description: "Automatically runs prettier on all your pull requests."
|
||||
|
||||
author: Conrad Großer <grosserconrad@gmail.com>
|
||||
|
||||
@@ -7,24 +7,25 @@ inputs:
|
||||
commit_message:
|
||||
description: Commit message
|
||||
required: false
|
||||
default: 'Prettified Code!'
|
||||
default: "Prettified Code!"
|
||||
commit_options:
|
||||
description: Commit options
|
||||
required: false
|
||||
file_pattern:
|
||||
description: File pattern used for "git add"
|
||||
required: false
|
||||
default: '*'
|
||||
default: "*"
|
||||
prettier_options:
|
||||
description: Options for the 'prettier' command
|
||||
required: true
|
||||
required: false
|
||||
default: "--write **/*.js"
|
||||
branch:
|
||||
description: Branch which the changes are merged to
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
args:
|
||||
- ${{ inputs.commit_message }}
|
||||
- ${{ inputs.commit_options }}
|
||||
@@ -33,5 +34,5 @@ runs:
|
||||
- ${{ inputs.branch }}
|
||||
|
||||
branding:
|
||||
icon: 'award'
|
||||
color: 'green'
|
||||
icon: "award"
|
||||
color: "green"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
set -eu
|
||||
#!/bin/sh
|
||||
# e is for exiting the script automatically if a command fails, u is for exiting if a variable is not set, x is for showing the commands before they are executed
|
||||
set -eux
|
||||
|
||||
# Function for setting up git env in the docker container (copied from https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh)
|
||||
git_setup ( ) {
|
||||
@@ -17,11 +17,11 @@ EOF
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "GitHub Actions"
|
||||
}
|
||||
echo "Installing dependencies..."
|
||||
npm install
|
||||
npm install --global prettier
|
||||
|
||||
echo "Installing prettier..."
|
||||
npm install --silent --global prettier
|
||||
echo "Prettifing files..."
|
||||
prettier $INPUT_PRETTIER_OPTIONS
|
||||
prettier $INPUT_PRETTIER_OPTIONS || echo "Problem while prettifying your files!"
|
||||
|
||||
if ! git diff --quiet
|
||||
then
|
||||
|
||||
Reference in New Issue
Block a user