Skip to content

GitHub Action to run actionlint via pre-commit and comment results on PRs using reviewdog.

License

Notifications You must be signed in to change notification settings

leinardi/gha-pre-commit-actionlint-reviewdog

Repository files navigation

Run actionlint via pre-commit + reviewdog

This GitHub Action runs the actionlint-oneline pre-commit hook on a diff range and reports results to pull requests using reviewdog.

Typical use case:

  • Run actionlint-oneline on changed workflow files
  • Annotate problems directly on the PR diff
  • Fail the job if violations are found

Requirements

Add the actionlint hooks to your .pre-commit-config.yaml, including the actionlint-oneline alias with the manual stage:

repos:
  - repo: https://github.com/rhysd/actionlint
    rev: v1.7.8
    hooks:
      - id: actionlint
        name: actionlint
        files: ^\.github/workflows/.*\.(yml|yaml)$
        args: ["-shellcheck"]
      - id: actionlint
        alias: actionlint-oneline
        name: actionlint (one line per one error)
        files: ^\.github/workflows/.*\.(yml|yaml)$
        args: ["-oneline", "-shellcheck"]
        stages: [manual]

You also need:

  • GitHub Actions enabled on the repository
  • secrets.GITHUB_TOKEN available (default on GitHub-hosted runners)
  • actions/checkout fetching enough history to include both from-ref and to-ref, for example:
- uses: actions/checkout@v4
  with:
    fetch-depth: 0

Inputs

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)

Outputs

Name Description
exitcode Exit code of the actionlint-oneline hook

Usage

Example workflow for pull requests:

name: Lint workflows with actionlint

on:
  pull_request:

jobs:
  actionlint:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Run actionlint via pre-commit + reviewdog
        uses: leinardi/gha-pre-commit-actionlint-reviewdog@v1
        with:
          from-ref: ${{ github.event.pull_request.base.sha }}
          to-ref: ${{ github.event.pull_request.head.sha }}
          github-token: ${{ secrets.GITHUB_TOKEN }}

Versioning

It’s recommended to pin to the major version:

uses: leinardi/gha-pre-commit-actionlint-reviewdog@v1

For fully reproducible behavior, pin to an exact tag:

uses: leinardi/[email protected]

About

GitHub Action to run actionlint via pre-commit and comment results on PRs using reviewdog.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •