Skip to content

feat: add hadolint

feat: add hadolint #6

Workflow file for this run

name: Lint Dockerfile
on:
workflow_dispatch:
pull_request:
push:
paths:
- "Dockerfile.template"
jobs:
lint:
name: 'Lint Dockerfile (PHP: ${{ matrix.php-version }})'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- '8.0'
- '8.1'
- '8.2'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Lint Dockerfile
id: hadolint
uses: hadolint/hadolint-action@master
with:
dockerfile: ./${{ matrix.php-version }}/Dockerfile
continue-on-error: true
- name: Set hadolint output for matrix
id: set_output
run: echo "::set-output name=result::PHP ${{ matrix.php-version }}: ${{ steps.hadolint.outcome }} - ${{ env.HADOLINT_RESULTS }}"

Check failure on line 34 in .github/workflows/lint.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/lint.yml

Invalid workflow file

You have an error in your yaml syntax on line 34
outputs:
lint-result: ${{ steps.set_output.outputs.result }}
comment:
needs: lint
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Consolidate and comment on PR
uses: actions/github-script@v6
with:
script: |
const lintResults = [ ${{ needs.lint.outputs.lint-result }} ];
const output = lintResults.map(result => {
return `
#### Hadolint: \`${result.split(" - ")[0]}\`
\`\`\`
${result.split(" - ")[1]}
\`\`\`
`;
}).join('\n\n');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
});