Skip to content

Commit 3d43e0e

Browse files
author
Gürkan İndibay
authored
Adds hadolint Dockerfile linter (#301)
1 parent e7cd955 commit 3d43e0e

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

.github/workflows/hadolint.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
# hadoint is a Dockerfile linter written in Haskell
6+
# that helps you build best practice Docker images.
7+
# More details at https://github.com/hadolint/hadolint
8+
9+
name: Hadolint
10+
11+
on:
12+
push:
13+
branches: [ "master", develop, nightly-builds ]
14+
pull_request:
15+
# The branches below must be a subset of the branches above
16+
branches: [ "master" ]
17+
schedule:
18+
- cron: '28 0 * * 3'
19+
20+
permissions:
21+
contents: read
22+
23+
jobs:
24+
hadolint:
25+
name: Run hadolint scanning
26+
runs-on: ubuntu-latest
27+
permissions:
28+
contents: read # for actions/checkout to fetch code
29+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
30+
pull-requests: write
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v3
35+
36+
- name: Run hadolint
37+
uses: hadolint/hadolint-action@f988afea3da57ee48710a9795b6bb677cc901183
38+
with:
39+
dockerfile: ./Dockerfile
40+
format: sarif
41+
output-file: hadolint-results.sarif
42+
no-fail: true
43+
44+
- name: Upload analysis results to GitHub
45+
uses: github/codeql-action/upload-sarif@v2
46+
with:
47+
sarif_file: hadolint-results.sarif
48+
wait-for-processing: true
49+
50+
- name: Update Pull Request
51+
uses: actions/github-script@v6
52+
if: github.event_name == 'pull_request'
53+
with:
54+
script: |
55+
const output = `
56+
#### Hadolint: \`${{ steps.hadolint.outcome }}\`
57+
\`\`\`
58+
${process.env.HADOLINT_RESULTS}
59+
\`\`\`
60+
`;
61+
62+
github.rest.issues.createComment({
63+
issue_number: context.issue.number,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: output
67+
})

0 commit comments

Comments
 (0)