forked from mage-ai/mage-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (63 loc) · 1.92 KB
/
lint_docker_image.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
57
58
59
60
61
62
63
64
65
66
67
name: Lint Docker Images
on:
pull_request:
paths:
- '*Dockerfile'
jobs:
changed-images:
runs-on: ubuntu-latest
name: List changed images
steps:
- name: Check out source repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v38
with:
files: '*Dockerfile'
json: true
- name: Create Job Matrix
id: image-matrix
run: echo images=${{ steps.changed-files.outputs.all_changed_files }} >> $GITHUB_OUTPUT
outputs:
images: ${{ steps.image-matrix.outputs.images }}
hadolint:
name: Lint Docker Images
runs-on: ubuntu-latest
permissions:
pull-requests: write
# Skip job if there are no images to test
# https://github.com/dorny/paths-filter/issues/66
if: ${{ needs.changed-images.outputs.images != '' && toJson(fromJson(needs.changed-images.outputs.images)) != '[]' }}
needs: [changed-images]
strategy:
matrix:
image: ${{ fromJSON(needs.changed-images.outputs.images) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: hadolint/[email protected]
id: hadolint
with:
dockerfile: ${{ matrix.image }}
ignore: DL3002,DL3008,DL3013,DL3016
- name: Annotate Pull Request
uses: actions/github-script@v6
if: github.event_name == 'pull_request' && failure()
with:
script: |
const output = `
#### Hadolint: \`${{ steps.hadolint.outcome }}\`
\`\`\`
${process.env.HADOLINT_RESULTS}
\`\`\`
`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})