Skip to content

Commit ce5efc6

Browse files
committed
Init for docker-build-check
1 parent 7a18c6b commit ce5efc6

File tree

12 files changed

+117
-243
lines changed

12 files changed

+117
-243
lines changed

.github/workflows/dockerimage.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/workflows/reviewdog.yml

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,12 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
13-
- uses: haya14busa/action-cond@v1
14-
id: reporter
15-
with:
16-
cond: ${{ github.event_name == 'pull_request' }}
17-
if_true: "github-pr-review"
18-
if_false: "github-check"
19-
- uses: reviewdog/action-shellcheck@v1
20-
with:
21-
github_token: ${{ secrets.github_token }}
22-
reporter: ${{ steps.reporter.outputs.value }}
23-
level: warning
24-
25-
hadolint:
26-
name: runner / hadolint
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v4
30-
- uses: haya14busa/action-cond@v1
31-
id: reporter
32-
with:
33-
cond: ${{ github.event_name == 'pull_request' }}
34-
if_true: "github-pr-review"
35-
if_false: "github-check"
36-
- uses: reviewdog/action-hadolint@v1
13+
- name: shellcheck
14+
uses: reviewdog/action-shellcheck@v1
3715
with:
3816
github_token: ${{ secrets.github_token }}
39-
reporter: ${{ steps.reporter.outputs.value }}
40-
level: warning
17+
reporter: github-pr-review
18+
path: "."
19+
pattern: "*.sh"
20+
exclude: "./.git/*"
4121

42-
misspell:
43-
name: runner / misspell
44-
runs-on: ubuntu-latest
45-
steps:
46-
- uses: actions/checkout@v4
47-
- uses: reviewdog/action-misspell@v1
48-
with:
49-
github_token: ${{ secrets.github_token }}
50-
reporter: github-check
51-
level: warning
52-
locale: "US"
53-
54-
alex:
55-
name: runner / alex
56-
runs-on: ubuntu-latest
57-
steps:
58-
- uses: actions/checkout@v4
59-
- uses: reviewdog/action-alex@v1
60-
with:
61-
github_token: ${{ secrets.github_token }}
62-
reporter: github-check
63-
level: warning

.github/workflows/test.yml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,11 @@ on:
55
- master
66
pull_request:
77
jobs:
8-
test-check:
9-
name: runner / <linter-name> (github-check)
8+
test-docker-build-check:
9+
name: test-docker-build-check
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4
1313
- uses: ./
1414
with:
1515
github_token: ${{ secrets.github_token }}
16-
reporter: github-check
17-
level: info
18-
locale: "US"
19-
20-
test-pr-check:
21-
if: github.event_name == 'pull_request'
22-
name: runner / <linter-name> (github-pr-check)
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
- uses: ./
27-
with:
28-
github_token: ${{ secrets.github_token }}
29-
reporter: github-pr-check
30-
level: warning
31-
locale: "US"
32-
workdir: ./testdata/subdir/
33-
34-
test-pr-review:
35-
if: github.event_name == 'pull_request'
36-
name: runner / <linter-name> (github-pr-review)
37-
runs-on: ubuntu-latest
38-
steps:
39-
- uses: actions/checkout@v4
40-
- uses: ./
41-
with:
42-
github_token: ${{ secrets.github_token }}
43-
reporter: github-pr-review
44-
level: error
45-
locale: "US"
46-
reviewdog_flags: -filter-mode=file -fail-on-error

Dockerfile

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,27 @@
1-
# action-template
1+
# GitHub Action: Run `docker build --check` with action-docker-build-check
22

3-
<!-- TODO: replace reviewdog/action-template with your repo name -->
4-
[![Test](https://github.com/reviewdog/action-template/workflows/Test/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3ATest)
5-
[![reviewdog](https://github.com/reviewdog/action-template/workflows/reviewdog/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Areviewdog)
6-
[![depup](https://github.com/reviewdog/action-template/workflows/depup/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Adepup)
7-
[![release](https://github.com/reviewdog/action-template/workflows/release/badge.svg)](https://github.com/reviewdog/action-template/actions?query=workflow%3Arelease)
8-
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/reviewdog/action-template?logo=github&sort=semver)](https://github.com/reviewdog/action-template/releases)
9-
[![action-bumpr supported](https://img.shields.io/badge/bumpr-supported-ff69b4?logo=github&link=https://github.com/haya14busa/action-bumpr)](https://github.com/haya14busa/action-bumpr)
3+
// TODO: Add status badges
104

11-
![github-pr-review demo](https://user-images.githubusercontent.com/3797062/73162963-4b8e2b00-4132-11ea-9a3f-f9c6f624c79f.png)
12-
![github-pr-check demo](https://user-images.githubusercontent.com/3797062/73163032-70829e00-4132-11ea-8481-f213a37db354.png)
5+
This action runs `docker build --check` with reviewdog on pull requests to improve code review experience.
136

14-
This is a template repository for [reviewdog](https://github.com/reviewdog/reviewdog) action with release automation.
15-
Click `Use this template` button to create your reviewdog action :dog:!
7+
## Examples
168

17-
If you want to create your own reviewdog action from scratch without using this
18-
template, please check and copy release automation flow.
19-
It's important to manage release workflow and sync reviewdog version for all
20-
reviewdog actions.
21-
22-
This repo contains a sample action to run [misspell](https://github.com/client9/misspell).
23-
24-
## Input
25-
26-
<!-- TODO: update -->
27-
```yaml
28-
inputs:
29-
github_token:
30-
description: 'GITHUB_TOKEN'
31-
default: '${{ github.token }}'
32-
workdir:
33-
description: 'Working directory relative to the root directory.'
34-
default: '.'
35-
### Flags for reviewdog ###
36-
level:
37-
description: 'Report level for reviewdog [info,warning,error]'
38-
default: 'error'
39-
reporter:
40-
description: 'Reporter of reviewdog command [github-pr-check,github-check,github-pr-review].'
41-
default: 'github-pr-check'
42-
filter_mode:
43-
description: |
44-
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
45-
Default is added.
46-
default: 'added'
47-
fail_on_error:
48-
description: |
49-
Exit code for reviewdog when errors are found [true,false]
50-
Default is `false`.
51-
default: 'false'
52-
reviewdog_flags:
53-
description: 'Additional reviewdog flags'
54-
default: ''
55-
### Flags for <linter-name> ###
56-
locale:
57-
description: '-locale flag of misspell. (US/UK)'
58-
default: ''
59-
```
9+
// TODO
6010

6111
## Usage
62-
<!-- TODO: update. replace `template` with the linter name -->
6312

6413
```yaml
6514
name: reviewdog
6615
on: [pull_request]
6716
jobs:
68-
# TODO: change `linter_name`.
69-
linter_name:
70-
name: runner / <linter-name>
17+
docker-build-check:
18+
name: docker-build-check
7119
runs-on: ubuntu-latest
7220
steps:
7321
- uses: actions/checkout@v4
74-
- uses: reviewdog/action-template@v1
22+
- uses: reviewdog/action-docker-build-check@v1
7523
with:
7624
github_token: ${{ secrets.github_token }}
77-
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review].
7825
reporter: github-pr-review
79-
# Change reporter level if you need.
80-
# GitHub Status Check won't become failure with warning.
8126
level: warning
8227
```
83-
84-
## Development
85-
86-
### Release
87-
88-
#### [haya14busa/action-bumpr](https://github.com/haya14busa/action-bumpr)
89-
You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch).
90-
Pushing tag manually by yourself also work.
91-
92-
#### [haya14busa/action-update-semver](https://github.com/haya14busa/action-update-semver)
93-
94-
This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3.
95-
ref: https://help.github.com/en/articles/about-actions#versioning-your-action
96-
97-
### Lint - reviewdog integration
98-
99-
This reviewdog action template itself is integrated with reviewdog to run lints
100-
which is useful for Docker container based actions.
101-
102-
![reviewdog integration](https://user-images.githubusercontent.com/3797062/72735107-7fbb9600-3bde-11ea-8087-12af76e7ee6f.png)
103-
104-
Supported linters:
105-
106-
- [reviewdog/action-shellcheck](https://github.com/reviewdog/action-shellcheck)
107-
- [reviewdog/action-hadolint](https://github.com/reviewdog/action-hadolint)
108-
- [reviewdog/action-misspell](https://github.com/reviewdog/action-misspell)
109-
110-
### Dependencies Update Automation
111-
This repository uses [reviewdog/action-depup](https://github.com/reviewdog/action-depup) to update
112-
reviewdog version.
113-
114-
[![reviewdog depup demo](https://user-images.githubusercontent.com/3797062/73154254-170e7500-411a-11ea-8211-912e9de7c936.png)](https://github.com/reviewdog/action-template/pull/6)

action.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: 'TODO: Run <linter-name> with reviewdog'
2-
description: 'TODO: 🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
3-
author: 'TODO: <your-name>'
1+
name: 'Run docker build --check with reviewdog'
2+
description: 'TODO: 🐶 Run docker build --check with reviewdog on pull requests to improve code review experience.'
3+
author: 'shmokmt(reviwedog)'
44
inputs:
55
github_token:
66
description: 'GITHUB_TOKEN'
@@ -11,10 +11,10 @@ inputs:
1111
### Flags for reviewdog ###
1212
level:
1313
description: 'Report level for reviewdog [info,warning,error]'
14-
default: 'error'
14+
default: 'warning'
1515
reporter:
1616
description: 'Reporter of reviewdog command [github-pr-check,github-pr-review].'
17-
default: 'github-pr-check'
17+
default: 'github-pr-review'
1818
filter_mode:
1919
description: |
2020
Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
@@ -29,15 +29,31 @@ inputs:
2929
description: 'Additional reviewdog flags'
3030
default: ''
3131
### Flags for <linter-name> ###
32-
locale:
33-
description: '-locale flag of misspell. (US/UK)'
34-
default: ''
32+
# locale:
33+
# description: '-locale flag of misspell. (US/UK)'
34+
# default: ''
3535
runs:
36-
using: 'docker'
37-
image: 'Dockerfile'
36+
using: 'composite'
37+
steps:
38+
- run: $GITHUB_ACTION_PATH/script.sh
39+
id: docker-build-check
40+
shell: bash
41+
env:
42+
# We may want to allow specifying reviewdog version as
43+
# action's input, but let's start with hard coded latest stable version for reviewdog
44+
REVIEWDOG_VERSION: v0.20.2
45+
# INPUT_<VARIABLE_NAME> is not available in Composite run steps
46+
# https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611
47+
INPUT_GITHUB_TOKEN: ${{ inputs.github_token }}
48+
INPUT_WORKING_DIRECTORY: ${{ inputs.working_directory }}
49+
INPUT_LEVEL: ${{ inputs.level }}
50+
INPUT_REPORTER: ${{ inputs.reporter }}
51+
INPUT_TOOL_NAME: ${{ inputs.tool_name }}
52+
INPUT_FILTER_MODE: ${{ inputs.filter_mode }}
53+
INPUT_FAIL_ON_ERROR: ${{ inputs.fail_on_error }}
54+
INPUT_FLAGS: ${{ inputs.flags }}
3855

3956
# Ref: https://haya14busa.github.io/github-action-brandings/
40-
# TODO: update branding if you want.
4157
branding:
42-
icon: 'check'
58+
icon: 'box'
4359
color: 'blue'

entrypoint.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

script.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
6+
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
7+
8+
TEMP_PATH="$(mktemp -d)"
9+
PATH="${TEMP_PATH}:$PATH"
10+
11+
# echo "::group:: Installing Docker..."
12+
# # Re-install Docker Engine
13+
# for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
14+
# # Install from official script
15+
# curl -fsSL https://get.docker.com -o get-docker.sh
16+
# sudo sh get-docker.sh
17+
# echo "::endgroup"
18+
19+
echo "::group:: docker version"
20+
docker version
21+
echo "::endgroups::"
22+
23+
echo "::group:: docker buildx inspect"
24+
docker buildx inspect
25+
echo "::endgroups::"
26+
27+
echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/reviewdog'
28+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
29+
echo '::endgroup::'
30+
31+
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
32+
33+
docker_files=$(git ls-files --exclude='*Dockerfile*' --ignored --cached)
34+
35+
for docker_file in "${docker_files[@]}" ; do
36+
export DOCKER_FILE_PATH=${docker_file}
37+
check_result=$(docker build -f ${docker_file} --call=check,format=json . || true)
38+
echo check_result | jq to-rdjson.jq
39+
done
40+
41+
42+
# misspell -locale="${INPUT_LOCALE}" . \
43+
# | reviewdog -efm="%f:%l:%c: %m" \
44+
# -name="linter-name (misspell)" \
45+
# -reporter="${INPUT_REPORTER:-github-pr-check}" \
46+
# -filter-mode="${INPUT_FILTER_MODE}" \
47+
# -fail-on-error="${INPUT_FAIL_ON_ERROR}" \
48+
# -level="${INPUT_LEVEL}" \
49+
# ${INPUT_REVIEWDOG_FLAGS}

testdata/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# syntax=docker/dockerfile:1
2+
# check=error=false
3+
FROM alpine as test
4+
RUN "Hello, World!"

testdata/subdir/text.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)