-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (46 loc) · 1.68 KB
/
dockerfile-lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: hadolint
on:
pull_request:
branches:
- main
- master
paths:
- "dockerfiles/**"
- ".github/workflows/dockerfile-lint.yml"
merge_group:
jobs:
list-files:
runs-on: ubuntu-latest
outputs:
files: ${{ steps.list-files.outputs.files }}
steps:
- name: 🛎 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: 📄 List Dockefile files
id: list-files
run: |
# git diff --name-only の結果をもとに、Dockerfile 拡張子のファイルを取得して、JSON配列として $GITHUB_OUTPUT に files として出力する
echo "files=[$(git diff --diff-filter=ACM --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E 'Dockerfile$' | sed -r -e 's/dockerfiles\/(.+).Dockerfile/\1/' -e 's/^/"/' -e 's/$/",/' | tr -d '\n' | sed -e 's/,$//')]" >> $GITHUB_OUTPUT
lint:
runs-on: ubuntu-latest
needs: list-files
strategy:
matrix:
file: ${{ fromJson(needs.list-files.outputs.files) }}
fail-fast: false
steps:
- name: 🛎 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Docker build check
run: |
docker build --check -f dockerfiles/${{ matrix.file }}.Dockerfile .
- name: 🐳 hadolint
uses: hadolint/[email protected]
with:
dockerfile: dockerfiles/${{ matrix.file }}.Dockerfile