Skip to content

Commit

Permalink
Merge pull request #79 from ybiquitous/docker-to-composite
Browse files Browse the repository at this point in the history
Migrate to a composite run based action
  • Loading branch information
haya14busa authored Apr 13, 2022
2 parents 65f5c3e + baf3d6c commit d89c27b
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/depup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: haya14busa/action-depup@v1
id: depup
with:
file: Dockerfile
file: action.yml
version_name: REVIEWDOG_VERSION
repo: reviewdog/reviewdog

Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/dockerimage.yml

This file was deleted.

12 changes: 0 additions & 12 deletions Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# GitHub Action: Run stylelint with reviewdog

[![Docker Image CI](https://github.com/reviewdog/action-stylelint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-stylelint/actions)
[![depup](https://github.com/reviewdog/action-stylelint/workflows/depup/badge.svg)](https://github.com/reviewdog/action-stylelint/actions?query=workflow%3Adepup)
[![release](https://github.com/reviewdog/action-stylelint/workflows/release/badge.svg)](https://github.com/reviewdog/action-stylelint/actions?query=workflow%3Arelease)
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-stylelint?logo=github&sort=semver)](https://github.com/reviewdog/action-stylelint/releases)
Expand Down
19 changes: 17 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,23 @@ inputs:
description: "The directory from which to look for and run stylelint. Default: '.'"
default: '.'
runs:
using: 'docker'
image: 'Dockerfile'
using: 'composite'
steps:
- run: $GITHUB_ACTION_PATH/script.sh
shell: bash
env:
REVIEWDOG_VERSION: v0.14.0
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
INPUT_LEVEL: ${{ inputs.level }}
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
INPUT_NAME: ${{ inputs.name }}
INPUT_PACKAGES: ${{ inputs.packages }}
INPUT_REPORTER: ${{ inputs.reporter }}
INPUT_STYLELINT_INPUT: ${{ inputs.stylelint_input }}
INPUT_STYLELINT_CONFIG: ${{ inputs.stylelint_config }}
INPUT_STYLELINT_IGNORE: ${{ inputs.stylelint_ignore }}
INPUT_WORKDIR: ${{ inputs.workdir }}
branding:
icon: 'alert-triangle'
color: 'yellow'
29 changes: 0 additions & 29 deletions entrypoint.sh

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "action-stylelint",
"version": "1.0.0",
"description": "[![Docker Image CI](https://github.com/reviewdog/action-stylelint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-stylelint/actions) [![Release](https://img.shields.io/github/release/reviewdog/action-stylelint.svg?maxAge=43200)](https://github.com/reviewdog/action-stylelint/releases)",
"description": "GitHub Action: Run stylelint with reviewdog",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
40 changes: 40 additions & 0 deletions script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1

TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"

echo '::group:: Installing reviewdog 🐶 ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
echo '::endgroup::'

if [ ! -f "$(npm bin)/stylelint" ]; then
echo '::group:: Running `npm install` to install stylelint ...'
npm install
echo '::endgroup::'
fi

if [ -n "${INPUT_PACKAGES}" ]; then
echo '::group:: Running `npm install` to install input packages ...'
npm install ${INPUT_PACKAGES}
echo '::endgroup::'
fi

echo "stylelint version: $($(npm bin)/stylelint --version)"

echo '::group:: Running stylelint with reviewdog 🐶 ...'
if [ "${INPUT_REPORTER}" = 'github-pr-review' ]; then
# Use jq and github-pr-review reporter to format result to include link to rule page.
$(npm bin)/stylelint "${INPUT_STYLELINT_INPUT}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" -f json \
| jq -r '.[] | {source: .source, warnings:.warnings[]} | "\(.source):\(.warnings.line):\(.warnings.column):\(.warnings.severity): \(.warnings.text) [\(.warnings.rule)](https://stylelint.io/user-guide/rules/\(.warnings.rule))"' \
| reviewdog -efm="%f:%l:%c:%t%*[^:]: %m" -name="${INPUT_NAME}" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}"
else
$(npm bin)/stylelint "${INPUT_STYLELINT_INPUT}" --config="${INPUT_STYLELINT_CONFIG}" --ignore-pattern="${INPUT_STYLELINT_IGNORE}" \
| reviewdog -f="stylelint" -name="${INPUT_NAME}" -reporter="${INPUT_REPORTER}" -level="${INPUT_LEVEL}" -filter-mode="${INPUT_FILTER_MODE}" -fail-on-error="${INPUT_FAIL_ON_ERROR}"
fi

reviewdog_rc=$?
echo '::endgroup::'
exit $reviewdog_rc
2 changes: 1 addition & 1 deletion testdata-subproject/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "action-stylelint",
"version": "1.0.0",
"description": "[![Docker Image CI](https://github.com/reviewdog/action-stylelint/workflows/Docker%20Image%20CI/badge.svg)](https://github.com/reviewdog/action-stylelint/actions) [![Release](https://img.shields.io/github/release/reviewdog/action-stylelint.svg?maxAge=43200)](https://github.com/reviewdog/action-stylelint/releases)",
"description": "GitHub Action: Run stylelint with reviewdog",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

0 comments on commit d89c27b

Please sign in to comment.