From 08ea0ae5a14eb0e2a9e1e2267a9760f41b0ce763 Mon Sep 17 00:00:00 2001 From: Krzysztof Borowy Date: Thu, 5 Mar 2020 08:28:47 +0100 Subject: [PATCH] feat: move install and build to docker --- Dockerfile | 10 ++++++---- README.md | 17 +++++++++++------ action.yml | 5 ++++- package.json | 5 ++--- src/eslintRunner.ts | 2 +- start.sh | 14 +++++++------- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 57e626c..30d889d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,14 @@ COPY . /eslint_check_action WORKDIR /eslint_check_action -ENTRYPOINT ["/eslint_check_action/start.sh"] - LABEL maintainer="Krzysztof Borowy " -LABEL com.github.actions.name="ESLint check action" -LABEL com.github.actions.description="Run Eslint checks in project" +LABEL com.github.actions.name="ESLint check" +LABEL com.github.actions.description="Runs ESlint check in your project and annotate errors/warning in a PR." LABEL com.github.actions.icon="octagon" LABEL com.github.actions.color="green" +RUN ["yarn", "install"] +RUN ["yarn", "build"] + +ENTRYPOINT ["/eslint_check_action/start.sh"] diff --git a/README.md b/README.md index 9c5384a..57594a5 100644 --- a/README.md +++ b/README.md @@ -2,25 +2,30 @@ GitHub action running eslint check in your project, annotating errors/warnings in PR. + +## Features + +- Customizable +- Installs project dependencies if missing +- Annotates lines in PR with warnings and errors + ## Usage Add workflow to your project (ex. `.github/workflows/eslint.yml`): ```yaml -name: Eslint check +name: Lint on: [push] jobs: eslint_check: - name: prepare + name: Prepare action runs-on: ubuntu-latest steps: # Checkout action must run prior to eslint check - name: Checkout uses: actions/checkout@v1 - - name: Install dependencies - run: yarn install - name: Lint - uses: Krizzu/eslint-check-action@v1.0.0 + uses: Krizzu/eslint-check-action@v1.1.0 with: ghToken: ${{ secrets.GITHUB_TOKEN }} eslintFiles: "lib, scripts" @@ -44,7 +49,7 @@ Default: `.eslintrc` **eslintExt** -File extension to run linting on. +File extension to run linting on. Default: `js, ts, jsx, tsx` ## License diff --git a/action.yml b/action.yml index d469b2f..b05e45a 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'Eslint check action' +name: 'Eslint check' description: "GitHub action running eslint check in your project, annotating errors/warnings in PR." author: "krizzu" inputs: @@ -6,12 +6,15 @@ inputs: description: 'GitHub token' required: true eslintFiles: + required: false description: 'Relative path to files/directories to run lint on.' default: '.' eslintConfig: + required: false description: 'Relative path to eslint config. Can either be ".js" config, ".eslintrc" or "package.json".' default: '.eslintrc' eslintExt: + required: false description: 'File extension to run linting on.' default: 'js, ts, jsx, tsx' runs: diff --git a/package.json b/package.json index 573779e..8320b2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@krizzu/eslint-check-action", - "version": "1.0.1", + "version": "1.1.0", "description": "GitHub action running eslint check in your project, annotating errors/warnings in PR.", "main": "dist/index.js", "author": "Krzysztof Borowy ", @@ -8,8 +8,7 @@ "scripts": { "test": "tsc", "dev": "source .env && yarn build && node dist/index.js", - "build": "rm -rf dist/ && babel src --out-dir dist/ --extensions .ts", - "prepublishOnly": "yarn build" + "build": "rm -rf dist/ && babel src --out-dir dist/ --extensions .ts" }, "dependencies": { "@actions/core": "1.2.0", diff --git a/src/eslintRunner.ts b/src/eslintRunner.ts index 800c635..966fcdd 100644 --- a/src/eslintRunner.ts +++ b/src/eslintRunner.ts @@ -4,7 +4,7 @@ import eslint from 'eslint'; import path from 'path'; class EslintRunner { - private name = 'Eslint check Action'; + private name = 'Eslint Run'; private kit: GitHub; diff --git a/start.sh b/start.sh index 724b6f5..0041d36 100755 --- a/start.sh +++ b/start.sh @@ -1,13 +1,13 @@ #!/bin/sh -cd "/eslint_check_action" -yarn install +cd $GITHUB_WORKSPACE -main=./dist/index.js - -if [ ! -f "$main" ]; then - yarn build +if [ ! -d "node_modules" ]; then + echo "Repo dependencies not installed. Installing..." + yarn install fi -node "$main" +cd "/eslint_check_action" || exit + +node "/eslint_check_action/dist/index.js"