18 Commits
v1.0 ... v2.0

Author SHA1 Message Date
a3b4af5f5b Update README.md 2020-01-24 20:48:26 +01:00
0b7dd998bb Improved Readme Commenting 2020-01-24 20:31:22 +01:00
554e56f267 Code Quality Improvements 2020-01-24 20:00:58 +01:00
f18a80caf3 Removed unused ls 2020-01-24 19:29:16 +01:00
cbf12d08d5 Removed unneccessary dependency install 2020-01-24 12:44:10 +01:00
7524f50124 Fixed a bug where the prettier default option didn't work 2020-01-24 12:29:00 +01:00
e1f9dea8d5 Added verbose shell output 2020-01-24 12:13:02 +01:00
43b949365d Update action.yml 2020-01-24 12:11:22 +01:00
d2b9447220 Fixed a bug where the default for prettier didn't work 2020-01-24 12:01:06 +01:00
01d985bf80 Fixed Broken Link in Readme 2020-01-22 13:55:59 +01:00
073765dcfc Create .gitignore 2020-01-17 09:38:06 +01:00
ce8fd0f388 Added comments for set parameters 2020-01-17 09:27:09 +01:00
90fb642c22 Fixed bug with exception 2020-01-17 09:24:14 +01:00
610abaf402 Added exception for prettier 2020-01-16 21:10:05 +01:00
a7de566991 Added default option for prettier 2020-01-16 16:59:41 +01:00
07dc95a6c7 Added silent execution for npm 2020-01-16 16:50:11 +01:00
25777abf08 Added usage example 2020-01-16 13:29:08 +01:00
0865129567 Update issue templates 2020-01-10 21:24:04 +01:00
6 changed files with 100 additions and 22 deletions

28
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View 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! -->

View 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
View File

@@ -0,0 +1,4 @@
# MacOS system files
.DS_Store
# NPM
node_modules/

View File

@@ -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).

View File

@@ -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"

View File

@@ -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