diff --git a/.github/workflows/depup.yml b/.github/workflows/depup.yml index dc03a09..925dd5d 100644 --- a/.github/workflows/depup.yml +++ b/.github/workflows/depup.yml @@ -11,24 +11,20 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: haya14busa/action-depup@v1 - id: depup + - uses: reviewdog/action-depup/with-pr@v1 with: - file: Dockerfile - version_name: REVIEWDOG_VERSION + file: action.yml + version_name: reviewdog_version repo: reviewdog/reviewdog + labels: "bump:minor" - - name: Create Pull Request - uses: peter-evans/create-pull-request@v3 + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: reviewdog/action-depup/with-pr@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} - title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" - commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" - body: | - Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) - Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) - - This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). - branch: depup/reviewdog - base: master + file: action.yml + version_name: SHELLCHECK_VERSION + repo: koalaman/shellcheck labels: "bump:minor" diff --git a/.github/workflows/dockerimage.yml b/.github/workflows/dockerimage.yml deleted file mode 100644 index 35a6b1c..0000000 --- a/.github/workflows/dockerimage.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Docker Image CI - -on: [push] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag reviewdog-shellcheck:$(date +%s) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f5ea3b8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM koalaman/shellcheck-alpine:latest - -ENV REVIEWDOG_VERSION=v0.13.0 - -RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION} -RUN apk --update add jq git findutils && \ - rm -rf /var/lib/apt/lists/* && \ - rm /var/cache/apk/* - -COPY entrypoint.sh /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index fd23dd4..615ff1f 100644 --- a/action.yml +++ b/action.yml @@ -5,42 +5,71 @@ inputs: github_token: description: 'GITHUB_TOKEN.' default: '${{ github.token }}' + required: false level: description: 'Report level for reviewdog [info,warning,error]' default: 'error' + required: false reporter: description: | Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. Default is github-pr-check. github-pr-review can use Markdown and add a link to rule page in reviewdog reports. default: 'github-pr-check' + required: false filter_mode: description: | Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is added. default: 'added' + required: false fail_on_error: description: | Exit code for reviewdog when errors are found [true,false] Default is `false`. default: 'false' + required: false reviewdog_flags: description: 'Additional reviewdog flags' default: '' + required: false path: description: "Base directory to run shellcheck. Same as `[path]` of `find` command." default: '.' + required: false pattern: description: "File patterns of target files. Same as `-name [pattern]` of `find` command." default: '*.sh' + required: false exclude: description: "Exclude patterns of target files. Same as `-not -path [exclude]` of `find` command." shellcheck_flags: description: "Flags of shellcheck command." default: '--external-sources' + required: false runs: - using: 'docker' - image: 'Dockerfile' + using: "composite" + steps: + - uses: reviewdog/action-setup@v1 + with: + reviewdog_version: v0.13.0 + - run: $GITHUB_ACTION_PATH/script.sh + shell: bash + env: + SHELLCHECK_VERSION: 0.7.2 + # INPUT_ is not available in Composite run steps + # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 + INPUT_GITHUB_TOKEN: ${{ inputs.github_token }} + INPUT_LEVEL: ${{ inputs.level }} + INPUT_REPORTER: ${{ inputs.reporter }} + INPUT_FILTER_MODE: ${{ inputs.filter_mode }} + INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }} + INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} + INPUT_PATH: ${{ inputs.path }} + INPUT_PATTERN: ${{ inputs.pattern }} + INPUT_EXCLUDE: ${{ inputs.exclude }} + INPUT_SHELLCHECK_FLAGS: ${{ inputs.shellcheck_flags }} + branding: icon: 'zoom-in' color: 'purple' diff --git a/entrypoint.sh b/script.sh similarity index 76% rename from entrypoint.sh rename to script.sh index bf6be2c..89d86ba 100755 --- a/entrypoint.sh +++ b/script.sh @@ -1,5 +1,14 @@ #!/bin/sh +echo '::group:: Installing shellcheck ... https://github.com/koalaman/shellcheck' +TEMP_PATH="$(mktemp -d)" +cd "${TEMP_PATH}" t ad || exit +wget -qO- "https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar -xJf - +mkdir bin +cp "shellcheck-v$SHELLCHECK_VERSION/shellcheck" ./bin +PATH="${TEMP_PATH}/bin:$PATH" +echo '::endgroup::' + cd "${GITHUB_WORKSPACE}" || exit export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"