Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
exelban committed Oct 25, 2019
1 parent c5b21d9 commit b959f79
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.idea
.git
.DS_Store
.git
10 changes: 0 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
FROM exelban/baseimage:node-latest

LABEL name="stylelinter"
LABEL version="1.0.0"
LABEL repository="https://github.com/exelban/stylelint"
LABEL homepage="https://github.com/exelban/stylelint"
LABEL maintainer="Serhiy Mytrovtsiy <[email protected]>"
LABEL com.github.actions.name="stylelinter"
LABEL com.github.actions.description="GitHub Action that runs stylelint."
LABEL com.github.actions.icon="layout"
LABEL com.github.actions.color="black"

COPY LICENSE README.md /

COPY entrypoint.sh /entrypoint.sh
Expand Down
74 changes: 52 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@
GitHub Action that runs [stylelint](https://stylelint.io).

## Usage
To use stylelint in your workflow just add this step:

```yaml
- uses: exelban/stylelint@master
- name: stylelint
uses: actions-hub/stylelint@master
```
Or use docker image:
```yaml
- uses: "docker://exelban/stylelint:latest"
```
## Configuration
### .stylelintrc
By default, action will try to find an existing configuration file in the project.
If the configuration file will not found, it will be created with the next configuration:
### Default values
#### Configuration file
Action will check if stylelint is already installed. If not, it will install stylelint.
Also, its check if the configuration file exists (`.stylelintrc`).

By default action use next configuration:
```json
{
"extends": "stylelint-config-standard",
Expand All @@ -27,22 +23,56 @@ By default action use next configuration:
}
```

#### Pattern
If pattern is not provided, action will use default one: `*.css`.
```yaml
- uses: exelban/stylelint@master
with:
args: ./**/*.scss
```
### File pattern
If you want to specify which file or types must be validated.
You need to pass the pattern as `PATTERN` variable.
By default, it will try to find `*.css`.


#### Indentation
Indentation can be set by environment variable `INDENT_SPACES`.
### Indentation
Indentation can be set by environment variable `INDENT_SPACES`.
By default space indend is 2.

```yaml
- uses: exelban/stylelint@master
- uses: actions-hub/stylelint@master
env:
INDENT_SPACES: 4
```
## Example
### Default values
```bash
name: Test
on: [push]

jobs:
linters:
name: stylelint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions-hub/stylelint@master
```
### Environment varialbes
```bash
name: Test
on: [push]

jobs:
linters:
name: stylelint
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions-hub/stylelint@master
env:
PATTERN: "*.scss"
INDENT_SPACES: 4
```
## License
[MIT License](https://github.com/exelban/stylelint/blob/master/LICENSE)
[MIT License](https://github.com/actions-hub/stylelint/blob/master/LICENSE)
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: 'stylelinter'
description: 'GitHub Action that runs stylelint.'
author: 'Serhiy Mytrovtsiy <[email protected]>'
branding:
icon: 'layout'
color: 'black'
inputs:
INDENT_SPACES:
description: 'Space indentation'
runs:
using: 'docker'
image: 'Dockerfile'
17 changes: 8 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ stylelint_path="node_modules/.bin/stylelint"
indent_spaces=2

if [ ! -e stylelint_path ]; then
yarn add stylelint stylelint-config-standard --silent
yarn add stylelint stylelint-config-standard --silent
fi

if [ ! -e "./.stylelintrc" ]; then
if [ -z "${INDENT_SPACES-}" ]; then
indent_spaces=$INDENT_SPACES
fi
if [ -z "${INDENT_SPACES-}" ]; then
indent_spaces=$INDENT_SPACES
fi

echo "{
echo "{
\"extends\": \"stylelint-config-standard\",
\"rules\": {
\"indentation\": "$indent_spaces"
}
}" > .stylelintrc
fi

if [ -z "$*" ]; then
pattern="./*.css"
else
pattern="$*"
pattern="./*.css"
if [ ! -z "${PATTERN}" ]; then
pattern=$PATTERN
fi

sh -c "$stylelint_path $pattern"

0 comments on commit b959f79

Please sign in to comment.