├── .github ├── renovate.json └── workflows │ ├── depup.yml │ ├── release.yml │ ├── reviewdog.yml │ ├── test.yml │ └── yamllint.yml ├── LICENSE ├── README.md ├── action.yml ├── examples ├── example-github-pr-check.png └── example-github-pr-review.png ├── script.sh ├── testdata ├── Dockerfile ├── Dockerfile.dockerignore └── sub-dir │ └── Dockerfile └── to-rdjson.jq /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "labels": [ 6 | "bump:patch" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.github/workflows/depup.yml: -------------------------------------------------------------------------------- 1 | name: depup 2 | on: 3 | schedule: 4 | - cron: '14 14 * * *' # Runs at 14:14 UTC every day 5 | repository_dispatch: 6 | types: [depup] 7 | workflow_dispatch: 8 | 9 | jobs: 10 | reviewdog: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - uses: haya14busa/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 15 | id: depup 16 | with: 17 | file: action.yml 18 | version_name: REVIEWDOG_VERSION 19 | repo: reviewdog/reviewdog 20 | 21 | - name: Create Pull Request to update reviewdog 22 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 23 | with: 24 | token: ${{ secrets.GITHUB_TOKEN }} 25 | title: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 26 | commit-message: "chore(deps): update reviewdog to ${{ steps.depup.outputs.latest }}" 27 | body: | 28 | Update reviewdog to [v${{ steps.depup.outputs.latest }}](https://github.com/reviewdog/reviewdog/releases/tag/v${{ steps.depup.outputs.latest }}) 29 | 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 }}) 30 | 31 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 32 | branch: depup/reviewdog 33 | base: master 34 | labels: "bump:minor" 35 | 36 | hadolint: 37 | runs-on: ubuntu-latest 38 | steps: 39 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 40 | - uses: haya14busa/action-depup@94a1aaf4e4923064019214b48a43276218af7ad5 # v1.6.4 41 | id: depup 42 | with: 43 | file: action.yml 44 | version_name: HADOLINT_VERSION 45 | repo: hadolint/hadolint 46 | 47 | - name: Create Pull Request to update hadolint 48 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 49 | with: 50 | token: ${{ secrets.GITHUB_TOKEN }} 51 | title: "chore(deps): update hadolint to ${{ steps.depup.outputs.latest }}" 52 | commit-message: "chore(deps): update hadolint to ${{ steps.depup.outputs.latest }}" 53 | body: | 54 | Update hadolint to [v${{ steps.depup.outputs.latest }}](https://github.com/hadolint/hadolint/releases/tag/v${{ steps.depup.outputs.latest }}) 55 | Compare [v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}](https://github.com/hadolint/hadolint/compare/v${{ steps.depup.outputs.current }}...v${{ steps.depup.outputs.latest }}) 56 | 57 | This PR is auto generated by [depup workflow](https://github.com/${{ github.repository }}/actions?query=workflow%3Adepup). 58 | branch: depup/hadolint 59 | base: master 60 | labels: "bump:minor" 61 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | branches: 5 | - master 6 | tags: 7 | - 'v*.*.*' 8 | pull_request: 9 | types: 10 | - labeled 11 | 12 | jobs: 13 | release: 14 | if: github.event.action != 'labeled' 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 18 | 19 | # Bump version on merging Pull Requests with specific labels. 20 | # (bump:major,bump:minor,bump:patch) 21 | - id: bumpr 22 | if: "!startsWith(github.ref, 'refs/tags/')" 23 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 24 | 25 | # Update corresponding major and minor tag. 26 | # e.g. Update v1 and v1.2 when releasing v1.2.3 27 | - uses: haya14busa/action-update-semver@fb48464b2438ae82cc78237be61afb4f461265a1 # v1.2.1 28 | if: "!steps.bumpr.outputs.skip" 29 | with: 30 | tag: ${{ steps.bumpr.outputs.next_version }} 31 | 32 | # Get tag name. 33 | - id: tag 34 | uses: haya14busa/action-cond@94f77f7a80cd666cb3155084e428254fea4281fd # v1.2.1 35 | with: 36 | cond: "${{ startsWith(github.ref, 'refs/tags/') }}" 37 | if_true: ${{ github.ref }} 38 | if_false: ${{ steps.bumpr.outputs.next_version }} 39 | 40 | # Create release 41 | - if: "steps.tag.outputs.value != ''" 42 | env: 43 | TAG_NAME: ${{ steps.tag.outputs.value }} 44 | CURRENT: ${{ steps.bumpr.outputs.current_version }} 45 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 46 | run: | 47 | gh release create "${TAG_NAME}" -t "Release ${TAG_NAME/refs\/tags\//}" --generate-notes --notes-start-tag "${CURRENT}" 48 | 49 | release-check: 50 | if: github.event.action == 'labeled' 51 | runs-on: ubuntu-latest 52 | steps: 53 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 54 | - name: Post bumpr status comment 55 | uses: haya14busa/action-bumpr@78ab5a104d20896c9c9122c64221b3aecf1a8cbb # v1.10.0 56 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: reviewdog 2 | on: [pull_request] 3 | jobs: 4 | shellcheck: 5 | name: runner / shellcheck 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 9 | - name: shellcheck 10 | uses: reviewdog/action-shellcheck@57079a832290a049f49cee90984b072c870fb7d4 # v1.29.3 11 | with: 12 | github_token: ${{ secrets.github_token }} 13 | misspell: 14 | name: runner / misspell 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Check out code. 18 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 19 | - name: misspell 20 | uses: reviewdog/action-misspell@9daa94af4357dddb6fd3775de806bc0a8e98d3e4 # v1.26.3 21 | with: 22 | github_token: ${{ secrets.github_token }} 23 | locale: "US" 24 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: 7 | 8 | jobs: 9 | test-check: 10 | name: runner / hadolint (github-check) 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 14 | - uses: ./ 15 | with: 16 | reporter: github-check 17 | level: info 18 | exclude: Dockerfile.dockerignore 19 | 20 | test-pr-review: 21 | if: github.event_name == 'pull_request' 22 | name: runner / hadolint (github-pr-review) 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 26 | - uses: ./ 27 | with: 28 | reporter: github-pr-review 29 | filter_mode: diff_context 30 | exclude: Dockerfile.dockerignore 31 | -------------------------------------------------------------------------------- /.github/workflows/yamllint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: yamllint 3 | on: [pull_request] 4 | 5 | jobs: 6 | yamllint: 7 | name: check / yamllint 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 11 | - name: yamllint 12 | uses: reviewdog/action-yamllint@f01d8a48fd8d89f89895499fca2cff09f9e9e8c0 # v1.21.0 13 | with: 14 | github_token: ${{ secrets.github_token }} 15 | reporter: github-pr-review 16 | fail_level: any 17 | yamllint_flags: '-d "{extends: default, rules: {truthy: disable}}" .' 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Grachev Mikhail 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Action: Run hadolint with reviewdog 🐶 2 | 3 | [](./LICENSE) 4 | [](https://github.com/reviewdog/action-hadolint/actions?query=workflow%3Adepup) 5 | [](https://github.com/reviewdog/action-hadolint/actions?query=workflow%3Arelease) 6 | [](https://github.com/reviewdog/action-hadolint/releases) 7 | [](https://github.com/haya14busa/action-bumpr) 8 | 9 | This action runs [hadolint](https://github.com/hadolint/hadolint) with 10 | [reviewdog](https://github.com/reviewdog/reviewdog) on pull requests to lint Dockerfile 11 | and validate inline bash. 12 | 13 | ## Examples 14 | 15 | ### With `github-pr-check` 16 | 17 | By default, with `reporter: github-pr-check` an annotation is added to the line: 18 | 19 |  20 | 21 | ### With `github-pr-review` 22 | 23 | With `reporter: github-pr-review` a comment is added to the Pull Request Conversation: 24 | 25 |  26 | 27 | ## Inputs 28 | 29 | ### `github_token` 30 | 31 | Optional. `${{ github.token }}` is used by default. 32 | 33 | ### `hadolint_flags` 34 | 35 | Optional. Pass hadolint flags: 36 | ``` 37 | with: 38 | hadolint_flags: --trusted-registry docker.io 39 | ``` 40 | 41 | ### `hadolint_ignore` 42 | 43 | Optional. Pass hadolint rules to ignore them: 44 | ``` 45 | with: 46 | hadolint_ignore: DL3009 DL3008 47 | ``` 48 | 49 | ### `tool_name` 50 | 51 | Optional. Tool name to use for reviewdog reporter. Useful when running multiple 52 | actions with different config. 53 | 54 | ### `exclude` 55 | 56 | Optional. List of folders and files to exclude from checking. 57 | 58 | Use `/%FOLDER%/*` to exclude whole folder or `%FILENAME%` to exclude certain files. 59 | 60 | Note that you can use wildcard to exclude certain file extensions, like `Dockerfile.*` will exclude `Dockerfile.dev`, but will not exclude `Dockerfile`. 61 | 62 | You can combine those rules as you wish (i.e. exclude certain files from certain folders only): 63 | ```yaml 64 | with: 65 | exclude: | 66 | /vendor/* 67 | Dockerfile.* 68 | ``` 69 | 70 | ### `include` 71 | 72 | Optional. Defaults to `*Dockerfile*`. List of folders and files to use for checking. 73 | 74 | Use `/%FOLDER%/*` to include whole folder or `%FILENAME%` to include certain files. 75 | 76 | Note that you can use wildcard to include certain file extensions, like `Dockerfile.*` will include `Dockerfile.dev`, but will not include `Dockerfile`. 77 | 78 | You can combine those rules as you wish (i.e. exclude certain files from certain folders only): 79 | ```yaml 80 | with: 81 | include: | 82 | subfolder/Dockerfile.* 83 | ``` 84 | 85 | ### `level` 86 | 87 | Optional. Report level for reviewdog [`info`, `warning`, `error`]. 88 | It's same as `-level` flag of reviewdog. 89 | 90 | ### `reporter` 91 | 92 | Optional. Reporter of reviewdog command [`github-pr-check`, `github-pr-review`]. 93 | The default is `github-pr-check`. 94 | 95 | ### `filter_mode` 96 | 97 | Optional. Filtering mode for the reviewdog command [`added`, `diff_context`, `file`, `nofilter`]. 98 | Default is `added`. 99 | 100 | ### `fail_level` 101 | 102 | Optional. If set to `none`, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. 103 | Possible values: [`none`, `any`, `info`, `warning`, `error`] 104 | Default is `none`. 105 | 106 | ### `fail_on_error` 107 | 108 | Deprecated, use `fail_level` instead. 109 | Optional. Exit code for reviewdog when errors are found [`true`, `false`] 110 | Default is `false`. 111 | 112 | ### `reviewdog_flags` 113 | 114 | Optional. Additional reviewdog flags. 115 | 116 | ## Example usage 117 | 118 | ```yml 119 | name: reviewdog 120 | on: [pull_request] 121 | jobs: 122 | hadolint: 123 | name: runner / hadolint 124 | runs-on: ubuntu-latest 125 | steps: 126 | - name: Check out code 127 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 128 | - name: hadolint 129 | uses: reviewdog/action-hadolint@fc7ee4a9f71e521bc43e370819247b70e5327540 # v1.50.2 130 | with: 131 | reporter: github-pr-review # Default is github-pr-check 132 | ``` 133 | 134 | ## Sponsor 135 | 136 |
137 |
138 |
140 |
141 |