Skip to content
zap

GitHub Action

ast-grep GH Action

v1.5 Latest version

ast-grep GH Action

zap

ast-grep GH Action

A GH Action to run ast-grep custom rules

Installation

Copy and paste the following snippet into your .yml file.

              

- name: ast-grep GH Action

uses: ast-grep/[email protected]

Learn more about this action in ast-grep/action

Choose a version

ast-grep/action

A GitHub Action to run ast-grep linting!

image

See a more detailed setup guide in ast-grep's tooling guide.

Inputs

version

Optional The version of ast-grep to use in the action. Default is latest.

config

Optional The file path to ast-grep's project config relative to root dir. Default is sgconfig.yml.

paths

Optional File paths string, corresponding to PATHS passed to the ast-grep cli, to limit the paths the action runs on. Multiple file paths can be delimited by whitespaces.

Example usage

Basic

on: [push]

jobs:
  sg-lint:
    runs-on: ubuntu-latest
    name: Run ast-grep lint
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: ast-grep lint step
        uses: ast-grep/action@latest

Advanced

on: [push]

jobs:
  sg-lint:
    runs-on: ubuntu-latest
    name: Run ast-grep lint
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: ast-grep lint step
        uses: ast-grep/action@latest
        with:
          version: 0.17.1
          config: sgconfig.yml
          paths: src lib