This GitHub Action runs the ansible-lint-parseable pre-commit hook on a ref
range and reports diagnostics to pull requests using reviewdog.
Typical use case:
- Run
ansible-linton changed Ansible/YAML files - Get one-line, parseable output
- Annotate problems directly on the PR diff
- Fail the job if violations are found
Add the ansible-lint hooks to your .pre-commit-config.yaml, including the ansible-lint-parseable alias with the manual stage:
repos:
- repo: https://github.com/ansible/ansible-lint
rev: v25.5.0
hooks:
- id: ansible-lint
alias: ansible-lint-fix
name: ansible-lint-fix
always_run: false
files: \.(yml|yaml)$
exclude: ^\.github/.*
args: [--fix]
- id: ansible-lint
name: ansible-lint
always_run: false
files: \.(yml|yaml)$
exclude: ^\.github/.*
- id: ansible-lint
alias: ansible-lint-parseable
name: "ansible-lint (parseable output)"
args: ["-p"]
stages: [manual]You also need:
- GitHub Actions enabled on the repository
secrets.GITHUB_TOKENavailable (default on GitHub-hosted runners)actions/checkoutfetching enough history to include bothfrom-refandto-ref, for example:
- uses: actions/checkout@v4
with:
fetch-depth: 0| Name | Required | Description |
|---|---|---|
from-ref |
✅ | Base git ref (e.g. PR base SHA) |
to-ref |
✅ | Head git ref (e.g. PR head SHA) |
github-token |
✅ | GitHub token for reviewdog (secrets.GITHUB_TOKEN) |
| Name | Description |
|---|---|
exitcode |
Exit code returned by the ansible-lint-parseable hook |
Example workflow for pull requests:
name: Lint Ansible with ansible-lint
on:
pull_request:
jobs:
ansible-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run ansible-lint via pre-commit + reviewdog
uses: leinardi/gha-pre-commit-ansible-lint-reviewdog@v1
with:
from-ref: ${{ github.event.pull_request.base.sha }}
to-ref: ${{ github.event.pull_request.head.sha }}
github-token: ${{ secrets.GITHUB_TOKEN }}It’s recommended to pin to the major version:
uses: leinardi/gha-pre-commit-ansible-lint-reviewdog@v1For fully reproducible behavior, pin to an exact tag:
uses: leinardi/gha-pre-commit-ansible-lint-reviewdog@v1.0.0