commit 8887c617d2a6b260888462fbc1f91ed8570ffc03 Author: Serhiy Mytrovtsiy Date: Wed Aug 21 22:01:23 2019 +0200 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6a54b1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.idea +.git +.DS_Store \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..74ac67e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM exelban/baseimage:node-latest + +LABEL name="stylelint" \ + version="1.0.0" \ + repository="https://github.com/exelban/stylelint" \ + homepage="https://github.com/exelban/stylelint" \ + maintainer="Serhiy Mytrovtsiy " \ + com.github.actions.name="stylelint" \ + com.github.actions.description="GitHub Action that runs stylelint." \ + com.github.actions.icon="layout" \ + com.github.actions.color="black" + +COPY README.md / + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5367c2c --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# stylelint +GitHub Action that runs [stylelint](https://stylelint.io). + +## Usage + +```yaml +- uses: exelban/stylelint@master +``` + +### Default values +#### Configuration file +Action will check if stylelint is already installed. If not, it will install styleling. +Also its check if configuration file is exist (`.stylelintrc`). + +By default action use next configuration: +```json +{ + "extends": "stylelint-config-standard", + "rules": { + "indentation": 2 + } +} +``` + +#### Pattern +If pattern is not provided, action will use default one: `*.css`. +```yaml +- uses: exelban/stylelint@master + with: + args: ./**/*.scss +``` + +#### Indentation +Indentation can be set by environment variable `INDENT_SPACES`. + +```yaml +- uses: exelban/stylelint@master + env: + INDENT_SPACES: 4 +``` + +## License +[MIT License](https://github.com/exelban/stylelint/blob/master/LICENSE) \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..7e5daa9 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +set -e + +stylelint_path="node_modules/.bin/stylelint" +indent_spaces=2 + +if [ ! -e stylelint_path ]; then + yarn add stylelint stylelint-config-standard --silent +fi + +if [ ! -e "./.stylelintrc" ]; then + if [ -z "${INDENT_SPACES-}" ]; then + indent_spaces=$INDENT_SPACES + fi + + echo "{ + \"extends\": \"stylelint-config-standard\", + \"rules\": { + \"indentation\": "$indent_spaces" + } +}" > .stylelintrc +fi + +if [ -z "$*" ]; then + pattern="./*.css" +else + pattern="$*" +fi + +sh -c "$stylelint_path $pattern" \ No newline at end of file