From 1a63a75177f1d594f250f988b1a4f8478b37fb6f Mon Sep 17 00:00:00 2001 From: "Jon (JR) Price" Date: Tue, 23 Jan 2024 16:02:02 -0800 Subject: [PATCH 1/3] Testing hadolint --- .github/workflows/hadolint.yml | 34 ++++++++++++++++++++++++++++++++++ Dockerfile | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/hadolint.yml diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml new file mode 100644 index 0000000..805dab4 --- /dev/null +++ b/.github/workflows/hadolint.yml @@ -0,0 +1,34 @@ +name: Hadolint + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile + - name: Update Pull Request + uses: actions/github-script@v6 + if: github.event_name == 'pull_request' + 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 + }) \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2294387..f802fe1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM python:3.12-alpine +FROM python:latest +# FROM python:3.12-alpine LABEL "com.github.actions.name"="GitHub Action for python" LABEL "com.github.actions.description"="Run pylint and other commands" From 9181152ed69b168dc47cf28796927c63ea51f2ea Mon Sep 17 00:00:00 2001 From: "Jon (JR) Price" Date: Tue, 23 Jan 2024 16:07:21 -0800 Subject: [PATCH 2/3] Added testing action with no event filtering --- .github/workflows/hadolint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml index 805dab4..53522ba 100644 --- a/.github/workflows/hadolint.yml +++ b/.github/workflows/hadolint.yml @@ -16,7 +16,7 @@ jobs: dockerfile: Dockerfile - name: Update Pull Request uses: actions/github-script@v6 - if: github.event_name == 'pull_request' + # if: github.event_name == 'pull_request' with: script: | const output = ` From 976e322f44bbe3165367884f1f2e021850af5178 Mon Sep 17 00:00:00 2001 From: "Jon (JR) Price" Date: Tue, 23 Jan 2024 16:13:45 -0800 Subject: [PATCH 3/3] Fixed Dockerfile and hadlint --- .hadolint.yml | 9 +++++++++ Dockerfile | 11 +++++------ 2 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .hadolint.yml diff --git a/.hadolint.yml b/.hadolint.yml new file mode 100644 index 0000000..0da3071 --- /dev/null +++ b/.hadolint.yml @@ -0,0 +1,9 @@ +# Hadolint configuration file + +# configure ignore rules +# see https://github.com/hadolint/hadolint#rules for a list of available rules. +ignored: + - DL3018 + - DL3042 + - DL3013 + - DL3059 # multi run diff --git a/Dockerfile b/Dockerfile index f802fe1..8188ac6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,14 @@ -FROM python:latest -# FROM python:3.12-alpine +FROM python:3.12-alpine LABEL "com.github.actions.name"="GitHub Action for python" LABEL "com.github.actions.description"="Run pylint and other commands" LABEL "com.github.actions.icon"="upload-cloud" LABEL "com.github.actions.color"="green" -RUN apk add --no-cache bash build-base gcc -RUN pip install --upgrade pip -RUN pip install pylint pipenv -RUN python --version ; pip --version ; pylint --version +RUN apk add --no-cache bash build-base gcc && \ +pip install --upgrade pip && \ +pip install pylint pipenv && \ +python --version ; pip --version ; pylint --version COPY entrypoint.sh / RUN chmod +x /entrypoint.sh