actionlint

package module
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 41 Imported by: 0

README

actionlint

CI Status API Document Sponsor this project

actionlint is a static checker for GitHub Actions workflow files. Try it online!

This is an actively maintained fork of rhysd/actionlint. It carries the upstream checks plus cache safety policies enabled by default, configurable opt-in policy checks, composite action step validation, shell completion, and a first-party GitHub Action, and it ships attested binaries, a Docker image on GHCR and Docker Hub, and a Go module at actionlint.kjanat.dev. Report problems through this fork's issue tracker.

Features:

  • Syntax check for workflow files to check unexpected or missing keys following workflow syntax
  • Strong type check for ${{ }} expressions to catch several semantic errors like access to not existing property, type mismatches, ...
  • Actions usage check to check that inputs at with: and outputs in steps.{id}.outputs are correct
  • Reusable workflow check to check inputs/outputs/secrets of reusable workflows and workflow calls
  • shellcheck and pyflakes integrations for scripts at run:
  • Security checks; script injection by untrusted inputs, hard-coded credentials
  • Other several useful checks; glob syntax validation, dependencies check for needs:, runner label validation, cron syntax validation, ...

See the full list of checks done by actionlint.

A terminal running actionlint on a workflow file, reporting each problem with the offending line underlined

Example of a broken workflow

The same files the animation above records, run through both linters. This section is generated from them by scripts/check-readme, so it cannot drift.

docs/screenshots/demo-workflow.yaml:

name: Release
on:
  push:
    branches: [main]
jobs:
  build:
    strategy:
      matrix:
        node: ["20", "22"]
    runs-on: ubuntu-26.04
    timeout-minutes: ${{ matrix.node }}
    steps:
      - uses: actions/checkout@v7
      - run: npm run mock-api
        id: mock
        background: true
      - run: npm test
      - wait: api

docs/screenshots/actionlint.yaml:

# yaml-language-server: $schema=https://cdn.jsdelivr.net/npm/@kjanat/actionlint/actionlint.schema.json
---
policy:
  require-commit-hash: true

Upstream actionlint 1.7.12 reports 3: runner-label, syntax-check ×2

demo-workflow.yaml:10:14: label "ubuntu-26.04" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2025", "windows-2025-vs2026", "windows-2022", "windows-11-arm", "ubuntu-slim", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-24.04-arm", "ubuntu-22.04", "ubuntu-22.04-arm", "macos-latest", "macos-latest-xlarge", "macos-latest-large", "macos-26-intel", "macos-26-xlarge", "macos-26-large", "macos-26", "macos-15-intel", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xlarge", "macos-14-large", "macos-14", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file [runner-label]
   |
10 |     runs-on: ubuntu-26.04
   |              ^~~~~~~~~~~~
demo-workflow.yaml:16:9: unexpected key "background" for step to run shell command. expected one of "continue-on-error", "env", "id", "if", "name", "run", "shell", "timeout-minutes", "working-directory" [syntax-check]
   |
16 |         background: true
   |         ^~~~~~~~~~~
demo-workflow.yaml:18:9: step must run script with "run" section or run action with "uses" section [syntax-check]
   |
18 |       - wait: api
   |         ^~~~~

This fork 1.16.1 reports 3: expression, require-commit-hash, parallel-steps

demo-workflow.yaml:11:22: type of expression at "float number value" must be number but found type string [expression]
   |
11 |     timeout-minutes: ${{ matrix.node }}
   |                      ^~~
demo-workflow.yaml:13:15: the ref "v7" of action "actions/checkout@v7" is not a commit SHA. actions must be pinned to a full-length commit SHA (40 or 64 hexadecimal digits) because "require-commit-hash" is enabled in the "policy" configuration. see https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#using-third-party-actions for more details [require-commit-hash]
   |
13 |       - uses: actions/checkout@v7
   |               ^~~~~~~~~~~~~~~~~~~
demo-workflow.yaml:18:15: "api" is not the ID of a preceding background step. "wait" and "cancel" steps can only refer to an earlier step that has "background: true" [parallel-steps]
   |
18 |       - wait: api
   |               ^~~

Quick start

Install with npm, Homebrew, AUR, Scoop, or mise, or download a release archive. See the installation document for all options. To run it through npm:

npx @kjanat/actionlint

With a Go toolchain, install it from source:

go install actionlint.kjanat.dev/cmd/actionlint@latest

actionlint.kjanat.dev is a Go vanity import path. The Go toolchain resolves it to this GitHub repository, where the source, releases, and issue tracker live. Further reading available here: GOPROXY protocol. Check for yourself: curl https://proxy.golang.org/actionlint.kjanat.dev/@latest

Basically all you need to do is run the actionlint command in your repository. actionlint automatically detects workflows and checks errors. actionlint focuses on finding out mistakes. It tries to catch errors as much as possible and make false positives as minimal as possible.

actionlint

Another option to try actionlint is the online playground. Your browser can run actionlint through WebAssembly.

See the usage document for more details.

GitHub Action

This repository can be used directly as a Docker action. The prebuilt image includes actionlint, ShellCheck, and pyflakes, and reports problems as GitHub annotations by default. Docker container actions run only on Linux, and this action also needs a reachable Docker daemon. ubuntu-slim is not supported: its job runs in an unprivileged container with the Docker client but no daemon or Docker socket. Standard Ubuntu runners, including ubuntu-24.04-arm and ubuntu-26.04-arm, are supported by the published linux/amd64 and linux/arm64 image.

name: Lint GitHub Actions workflows
on: [push, pull_request]

jobs:
  actionlint:
    runs-on: ubuntu-latest
    steps:
      - { uses: actions/checkout@v7, with: { persist-credentials: false } }
      - uses: kjanat/actionlint@v1

On a daemon-less runner such as ubuntu-slim, download and run the binary instead:

- uses: actions/checkout@v7
  with: { persist-credentials: false }
- name: Download and run actionlint
  env: { GH_TOKEN: "${{ github.token }}", GH_REPO: "kjanat/actionlint" }
  run: |
    case "${RUNNER_ARCH}" in
      X64) asset_arch=amd64 ;;
      ARM64) asset_arch=arm64 ;;
      ARM) asset_arch=armv6 ;;
      X86) asset_arch=386 ;;
      *) echo "Unsupported runner architecture: ${RUNNER_ARCH}" >&2; exit 1 ;;
    esac
    gh release download --pattern "actionlint_*_${RUNNER_OS,,}_${asset_arch}.tar.gz" --output - | tar -xzf - actionlint
    ./actionlint -color

The moving v1 tag follows compatible v1 releases, and v1.16 follows v1.16 patch releases. These tags point to a commit immediately after the release that pins the published container image by digest. v1.17.0 is a versioned release tag. For an immutable action reference with a pinned image, use the full commit SHA resolved from a floating tag.

Inputs

Input Default Description
files all workflows Newline-separated workflow paths. Empty checks every workflow in the repository.
format github Output format: github, default, oneline, json, json-lines, markdown, or sarif.
ignore none Newline-separated regular expressions for actionlint errors to ignore.
config-file automatic Configuration file path relative to working-directory.
shellcheck true Run ShellCheck for shell scripts in workflow steps.
pyflakes true Run pyflakes for Python scripts in workflow steps.
working-directory . Directory to lint, relative to the repository workspace.
output-file none Repository-relative file to receive the selected output format.
fail-on-error true Fail when problems are found. Invalid options and fatal errors always fail.

Outputs

Output Description
exit-code actionlint exit code: 0 for clean, 1 for problems, 2 for invalid options, or 3 for failure.
result success, problems-found, invalid-options, or failure.
problems-found Whether actionlint found one or more problems.
problem-count Number of problems, or an empty string if actionlint could not complete.
output Complete actionlint output in the selected format.
output-file Repository-relative output path, or an empty string when no file was requested.

Give the step an id to consume its outputs. For example, this writes JSON Lines without failing the lint step:

- name: Check workflows
  id: actionlint
  uses: kjanat/actionlint@v1
  with:
    format: json-lines
    output-file: actionlint-results.jsonl
    fail-on-error: false
- name: Report result
  if: always()
  env:
    RESULT: ${{ steps.actionlint.outputs.result }}
    PROBLEM_COUNT: ${{ steps.actionlint.outputs.problem-count }}
  run: echo "${RESULT} (${PROBLEM_COUNT} problems)"

See the usage document for additional examples and output behavior.

pre-commit

Workflow files can be checked on every commit with pre-commit. Add this to .pre-commit-config.yaml:

---
repos:
  - repo: https://github.com/kjanat/actionlint
    rev: v1.17.0
    hooks: [id: actionlint]

Choosing a hook

Four hooks check .github/workflows/ the same way and differ only in where the actionlint executable comes from.

Hook ID Where the executable comes from Requires
actionlint Built from this repository into an isolated $GOPATH. Go toolchain
actionlint-shellcheck Same, plus a Go build of ShellCheck installed next to it. Go toolchain
actionlint-docker Pulls this repository's image from ghcr.io. Docker
actionlint-system Runs the actionlint already on PATH. A manual install

The actionlint hook installs into an isolated $GOPATH, so the ShellCheck integration finds a shellcheck executable only when one is already on PATH. actionlint-shellcheck supplies one itself, which is the option to pick when contributors should not have to install ShellCheck.

See the usage document for the pinned ShellCheck build and how to choose a different one.

Documents

  • Checks: Full list of all checks done by actionlint with example inputs, outputs, and playground links.
  • Installation: Install with npm, Homebrew, AUR, Scoop, aqua, mise, the community pip/uv wrapper, release archives, the download script, Docker, or Go. Includes the status of WinGet and upstream-only package names.
  • Usage: How to use actionlint command locally or on GitHub Actions, the online playground, an official Docker image, and integrations with reviewdog, Problem Matchers, super-linter, pre-commit, VS Code.
  • Configuration: Runner labels, variables, secrets, default permissions, error filters, and opt-in policy checks, with YAML Language Server schema support.
  • Go API: How to use actionlint as Go library.
  • Schema audit: Pinned upstream definitions, compatibility fixes, validation evidence, and retained differences.
  • References: Links to resources.
  • GitHub Actions changelog: Browse and search the latest entries from GitHub's Actions changelog feed.

Bug reporting

When you see some bugs or false positives, it is helpful to file a new issue with a minimal example of input. Feature requests and ideas for additional checks are welcome too.

See the contribution guide for more details.

License

actionlint is distributed under the MIT license.

Documentation

Overview

Package actionlint is the implementation of actionlint linter. It's a static checker for GitHub Actions workflow files.

https://github.com/kjanat/actionlint

actionlint is a command line tool but it also provides Go API for Go programs. It includes a workflow file parser built on top of yaml/go-yaml, lexer/parser/checker for expressions embedded by ${{ }} placeholder, popular actions data, available contexts information, etc.

To run the linter, Linter is the struct which manages the entire linter lifecycle. Please see the first example.

actionlint also provides the flexibility to add your own rules by implementing Rule interface. Please read the YourOwnRule example.

Library versioning

The version is for the command line tool. So it does not represent the version of the library. It means that the library does not follow semantic versioning and any patch version bump may introduce some breaking changes.

Go version compatibility

Minimum supported Go version is written in go.mod file in this library. That said, older Go versions are actually not tested on CI. Last two major Go versions are recommended because they're tested on CI. For example, when the latest Go version is v1.22, v1.21 and v1.22 are nice to use.

https://github.com/kjanat/actionlint/blob/HEAD/go.mod

Other documentations

All documentations for actionlint can be found in the following page.

https://github.com/kjanat/actionlint/tree/HEAD/docs

License

This library is provided under the MIT license.

> Copyright (c) 2021 rhysd

Full text can be found in the following page.

https://github.com/kjanat/actionlint/blob/HEAD/LICENSE.txt

Index

Examples

Constants

View Source
const (
	// RawYAMLValueKindObject is kind for an object value of raw YAML value.
	RawYAMLValueKindObject = RawYAMLValueKind(yaml.MappingNode)
	// RawYAMLValueKindArray is kind for an array value of raw YAML value.
	RawYAMLValueKindArray = RawYAMLValueKind(yaml.SequenceNode)
	// RawYAMLValueKindString is kind for a string value of raw YAML value.
	RawYAMLValueKindString = RawYAMLValueKind(yaml.ScalarNode)
)
View Source
const (
	// ExitStatusSuccessNoProblem is the exit status when the command ran successfully with no problem found.
	ExitStatusSuccessNoProblem = 0
	// ExitStatusSuccessProblemFound is the exit status when the command ran successfully with some problem found.
	ExitStatusSuccessProblemFound = 1
	// ExitStatusInvalidCommandOption is the exit status when parsing command line options failed.
	ExitStatusInvalidCommandOption = 2
	// ExitStatusFailure is the exit status when the command stopped due to some fatal error while checking workflows.
	ExitStatusFailure = 3
)
View Source
const (
	// LogLevelNone does not output any log output.
	LogLevelNone LogLevel = 0
	// LogLevelVerbose shows verbose log output. This is equivalent to specifying -verbose option
	// to actionlint command.
	LogLevelVerbose = 1
	// LogLevelDebug shows all log output including debug information.
	LogLevelDebug = 2
)

Variables

View Source
var ActionRuntimes = map[string]ActionRuntime{
	"node12": {Removed: true, Deprecated: false, DeprecationURL: "", RemovalDate: ""},
	"node16": {Removed: true, Deprecated: false, DeprecationURL: "", RemovalDate: ""},
	"node20": {Removed: false, Deprecated: true, DeprecationURL: "https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/", RemovalDate: "September 23rd, 2026"},
	"node24": {Removed: false, Deprecated: false, DeprecationURL: "", RemovalDate: ""},
}

ActionRuntimes records accepted metadata values and the lifecycle of their bundled executables.

View Source
var AllContexts = map[string][]string{"env": {"jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.defaults.run", "jobs.<job_id>.environment.url", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory"}, "github": {"concurrency", "env", "jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.if", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.strategy", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>", "on.workflow_call.inputs.<inputs_id>.default", "on.workflow_call.outputs.<output_id>.value", "run-name"}, "inputs": {"concurrency", "env", "jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.if", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.strategy", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>", "on.workflow_call.inputs.<inputs_id>.default", "on.workflow_call.outputs.<output_id>.value", "run-name"}, "job": {"jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.environment.url", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory"}, "jobs": {"on.workflow_call.outputs.<output_id>.value"}, "matrix": {"jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>"}, "needs": {"jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.if", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.strategy", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>"}, "runner": {"jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.environment.url", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory"}, "secrets": {"env", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.env", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory"}, "steps": {"jobs.<job_id>.environment.url", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory"}, "strategy": {"jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>"}, "vars": {"concurrency", "env", "jobs.<job_id>.cancel-timeout-minutes", "jobs.<job_id>.concurrency", "jobs.<job_id>.container", "jobs.<job_id>.container.credentials", "jobs.<job_id>.container.env.<env_id>", "jobs.<job_id>.container.image", "jobs.<job_id>.continue-on-error", "jobs.<job_id>.defaults.run", "jobs.<job_id>.env", "jobs.<job_id>.environment", "jobs.<job_id>.environment.url", "jobs.<job_id>.if", "jobs.<job_id>.name", "jobs.<job_id>.outputs.<output_id>", "jobs.<job_id>.runs-on", "jobs.<job_id>.secrets.<secrets_id>", "jobs.<job_id>.services", "jobs.<job_id>.services.<service_id>.credentials", "jobs.<job_id>.services.<service_id>.env.<env_id>", "jobs.<job_id>.snapshot", "jobs.<job_id>.snapshot.if", "jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.strategy", "jobs.<job_id>.timeout-minutes", "jobs.<job_id>.with.<with_id>", "on.workflow_call.inputs.<inputs_id>.default", "on.workflow_call.outputs.<output_id>.value", "run-name"}}

AllContexts is a map from context name to workflow key which allows the context. This variable was generated by scraping https://docs.github.com/en/actions/reference/workflows-and-actions/contexts See the script for more details: https://github.com/kjanat/actionlint/blob/HEAD/scripts/generate-availability/

View Source
var AllWebhookTypes = map[string][]string{
	"branch_protection_rule":      {"created", "edited", "deleted"},
	"check_run":                   {"created", "rerequested", "completed", "requested_action"},
	"check_suite":                 {"completed"},
	"create":                      {},
	"delete":                      {},
	"deployment":                  {},
	"deployment_status":           {},
	"discussion":                  {"created", "edited", "deleted", "transferred", "pinned", "unpinned", "labeled", "unlabeled", "locked", "unlocked", "category_changed", "answered", "unanswered"},
	"discussion_comment":          {"created", "edited", "deleted"},
	"fork":                        {},
	"gollum":                      {},
	"image_version":               {},
	"issue_comment":               {"created", "edited", "deleted"},
	"issues":                      {"opened", "edited", "deleted", "transferred", "pinned", "unpinned", "closed", "reopened", "assigned", "unassigned", "labeled", "unlabeled", "locked", "unlocked", "milestoned", "demilestoned", "typed", "untyped", "field_added", "field_removed"},
	"label":                       {"created", "edited", "deleted"},
	"merge_group":                 {"checks_requested", "destroyed"},
	"milestone":                   {"created", "closed", "opened", "edited", "deleted"},
	"page_build":                  {},
	"public":                      {},
	"pull_request":                {"assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened", "synchronize", "converted_to_draft", "locked", "unlocked", "enqueued", "dequeued", "milestoned", "demilestoned", "ready_for_review", "review_requested", "review_request_removed", "auto_merge_enabled", "auto_merge_disabled", "stacked"},
	"pull_request_review":         {"submitted", "edited", "dismissed"},
	"pull_request_review_comment": {"created", "edited", "deleted"},
	"pull_request_target":         {"assigned", "unassigned", "labeled", "unlabeled", "opened", "edited", "closed", "reopened", "synchronize", "converted_to_draft", "locked", "unlocked", "enqueued", "dequeued", "milestoned", "demilestoned", "ready_for_review", "review_requested", "review_request_removed", "auto_merge_enabled", "auto_merge_disabled", "stacked"},
	"push":                        {},
	"registry_package":            {"published", "updated"},
	"release":                     {"published", "unpublished", "created", "edited", "deleted", "prereleased", "released"},
	"repository_dispatch":         nil,
	"schedule":                    {},
	"status":                      {},
	"watch":                       {"started"},
	"workflow_call":               {},
	"workflow_dispatch":           {},
	"workflow_run":                {"completed", "requested", "in_progress"},
}

AllWebhookTypes is a table of all webhooks with their types. This variable was generated by script at ./scripts/generate-webhook-events based on https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows The value is nil when the activity types cannot be determined from the document. For example repository_dispatch event can contain arbitrary types that are customized by user.

View Source
var BrandingColors = map[string]struct{}{
	"white":     {},
	"black":     {},
	"yellow":    {},
	"blue":      {},
	"green":     {},
	"orange":    {},
	"red":       {},
	"purple":    {},
	"gray-dark": {},
}

BrandingColors is a set of colors allowed at branding.color in action.yaml. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#brandingcolor Agents: https://docs.github.com/api/article/body?pathname=/en/actions/reference/workflows-and-actions/metadata-syntax

View Source
var BrandingIcons = map[string]struct{}{}/* 257 elements not displayed */

BrandingIcons is a set of icon names allowed at branding.icon in action.yaml. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#brandingicon

Note: The list of icons is based on [Feather Icons](https://feathericons.com/) [v4.28.0](https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/icons.json).

Omitted icons: Brand icons, and all the following icons, are omitted.

- coffee - columns - divide - divide-circle - divide-square - frown - hexagon - key - meh - mouse-pointer - smile - tool - x-octagon

TODO:

generate the list of icons from the Feather Icons JSON file to keep it up-to-date.
and embed the JSON file in the binary to avoid this crap.
View Source
var BuiltinFuncSignatures = map[string][]*FuncSignature{
	"contains": {
		{
			Name: "contains",
			Ret:  BoolType{},
			Params: []ExprType{
				StringType{},
				StringType{},
			},
			IsConstFunc: true,
		},
		{
			Name: "contains",
			Ret:  BoolType{},
			Params: []ExprType{
				&ArrayType{Elem: AnyType{}},
				AnyType{},
			},
			IsConstFunc: true,
		},
	},
	"startswith": {{
		Name: "startsWith",
		Ret:  BoolType{},
		Params: []ExprType{
			StringType{},
			StringType{},
		},
		IsConstFunc: true,
	}},
	"endswith": {{
		Name: "endsWith",
		Ret:  BoolType{},
		Params: []ExprType{
			StringType{},
			StringType{},
		},
		IsConstFunc: true,
	}},
	"format": {{
		Name:        "format",
		Ret:         StringType{},
		Params:      []ExprType{StringType{}},
		IsConstFunc: true,
	}, {
		Name: "format",
		Ret:  StringType{},
		Params: []ExprType{
			StringType{},
			AnyType{},
		},
		VariableLengthParams: true,
		IsConstFunc:          true,
	}},
	"join": {
		{
			Name:        "join",
			Ret:         StringType{},
			Params:      []ExprType{StringType{}},
			IsConstFunc: true,
		},
		{
			Name:        "join",
			Ret:         StringType{},
			Params:      []ExprType{StringType{}, StringType{}},
			IsConstFunc: true,
		},
		{
			Name: "join",
			Ret:  StringType{},
			Params: []ExprType{
				&ArrayType{Elem: StringType{}},
				StringType{},
			},
			IsConstFunc: true,
		},

		{
			Name: "join",
			Ret:  StringType{},
			Params: []ExprType{
				&ArrayType{Elem: StringType{}},
			},
			IsConstFunc: true,
		},
	},
	"tojson": {{
		Name: "toJSON",
		Ret:  StringType{},
		Params: []ExprType{
			AnyType{},
		},
		IsConstFunc: true,
	}},
	"fromjson": {{
		Name: "fromJSON",
		Ret:  AnyType{},
		Params: []ExprType{
			StringType{},
		},
	}},
	"hashfiles": {{
		Name: "hashFiles",
		Ret:  StringType{},
		Params: []ExprType{
			StringType{},
		},
		VariableLengthParams: true,
	}},
	"success": {{
		Name:   "success",
		Ret:    BoolType{},
		Params: []ExprType{},
	}},
	"always": {{
		Name:   "always",
		Ret:    BoolType{},
		Params: []ExprType{},
	}},
	"cancelled": {{
		Name:   "cancelled",
		Ret:    BoolType{},
		Params: []ExprType{},
	}},
	"failure": {{
		Name:   "failure",
		Ret:    BoolType{},
		Params: []ExprType{},
	}},
	"case": {{
		Name: "case",
		Ret:  AnyType{},
		Params: []ExprType{
			BoolType{},
			AnyType{},
			AnyType{},
		},
		VariableLengthParams: true,
		IsConstFunc:          true,
	}},
}

BuiltinFuncSignatures is a set of all builtin function signatures. All function names are in lower case because function names are compared in case insensitive. https://docs.github.com/en/actions/learn-github-actions/expressions#functions

View Source
var BuiltinGlobalVariableTypes = map[string]ExprType{

	"github": NewStrictObjectType(map[string]ExprType{
		"action":                    StringType{},
		"action_path":               StringType{},
		"action_ref":                StringType{},
		"action_repository":         StringType{},
		"action_status":             StringType{},
		"actor":                     StringType{},
		"actor_id":                  StringType{},
		"api_url":                   StringType{},
		"artifact_cache_size_limit": NumberType{},
		"artifacts":                 StringType{},
		"artifacts_list":            StringType{},
		"base_ref":                  StringType{},
		"env":                       StringType{},
		"event":                     NewEmptyObjectType(),
		"event_name":                StringType{},
		"event_path":                StringType{},
		"graphql_url":               StringType{},
		"head_ref":                  StringType{},
		"job":                       StringType{},
		"output":                    StringType{},
		"path":                      StringType{},
		"ref":                       StringType{},
		"ref_name":                  StringType{},
		"ref_protected":             BoolType{},
		"ref_type":                  StringType{},
		"repository":                StringType{},
		"repository_id":             StringType{},
		"repository_owner":          StringType{},
		"repository_owner_id":       StringType{},
		"repository_visibility":     StringType{},
		"repositoryurl":             StringType{},
		"retention_days":            StringType{},
		"run_attempt":               StringType{},
		"run_id":                    StringType{},
		"run_number":                StringType{},
		"secret_source":             StringType{},
		"server_url":                StringType{},
		"sha":                       StringType{},
		"state":                     StringType{},
		"step_summary":              StringType{},
		"token":                     StringType{},
		"triggering_actor":          StringType{},
		"workflow":                  StringType{},
		"workflow_ref":              StringType{},
		"workflow_sha":              StringType{},
		"workspace":                 StringType{},
	}),

	"env": NewMapObjectType(StringType{}),

	"job": NewStrictObjectType(map[string]ExprType{
		"check_run_id": NumberType{},
		"container": NewStrictObjectType(map[string]ExprType{
			"id":      StringType{},
			"network": StringType{},
		}),
		"services": NewMapObjectType(
			NewStrictObjectType(map[string]ExprType{
				"id":      StringType{},
				"network": StringType{},
				"ports":   NewMapObjectType(StringType{}),
			}),
		),
		"status":              StringType{},
		"workflow_file_path":  StringType{},
		"workflow_ref":        StringType{},
		"workflow_repository": StringType{},
		"workflow_sha":        StringType{},
	}),

	"steps": NewEmptyStrictObjectType(),

	"runner": NewStrictObjectType(map[string]ExprType{
		"name":        StringType{},
		"os":          StringType{},
		"arch":        StringType{},
		"temp":        StringType{},
		"tool_cache":  StringType{},
		"debug":       StringType{},
		"environment": StringType{},
	}),

	"secrets": &ObjectType{
		Props:  maps.Clone(builtinSecretProps),
		Mapped: StringType{},
	},

	"strategy": NewObjectType(map[string]ExprType{
		"fail-fast":    BoolType{},
		"job-index":    NumberType{},
		"job-total":    NumberType{},
		"max-parallel": NumberType{},
	}),

	"matrix": NewEmptyStrictObjectType(),

	"needs": NewEmptyStrictObjectType(),

	"inputs": NewEmptyStrictObjectType(),

	"vars": NewMapObjectType(StringType{}),
}

BuiltinGlobalVariableTypes defines types of all global variables. All context variables are documented at https://docs.github.com/en/actions/learn-github-actions/contexts

View Source
var BuiltinUntrustedInputs = UntrustedInputSearchRoots{
	"github": NewUntrustedInputMap("github",
		NewUntrustedInputMap("event",
			NewUntrustedInputMap("issue",
				NewUntrustedInputMap("title"),
				NewUntrustedInputMap("body"),
			),
			NewUntrustedInputMap("pull_request",
				NewUntrustedInputMap("title"),
				NewUntrustedInputMap("body"),
				NewUntrustedInputMap("head",
					NewUntrustedInputMap("ref"),
					NewUntrustedInputMap("label"),
					NewUntrustedInputMap("repo",
						NewUntrustedInputMap("default_branch"),
					),
				),
			),
			NewUntrustedInputMap("comment",
				NewUntrustedInputMap("body"),
			),
			NewUntrustedInputMap("review",
				NewUntrustedInputMap("body"),
			),
			NewUntrustedInputMap("review_comment",
				NewUntrustedInputMap("body"),
			),
			NewUntrustedInputMap("pages",
				NewUntrustedInputMap("*",
					NewUntrustedInputMap("page_name"),
				),
			),
			NewUntrustedInputMap("commits",
				NewUntrustedInputMap("*",
					NewUntrustedInputMap("message"),
					NewUntrustedInputMap("author",
						NewUntrustedInputMap("email"),
						NewUntrustedInputMap("name"),
					),
				),
			),
			NewUntrustedInputMap("head_commit",
				NewUntrustedInputMap("message"),
				NewUntrustedInputMap("author",
					NewUntrustedInputMap("email"),
					NewUntrustedInputMap("name"),
				),
			),
			NewUntrustedInputMap("discussion",
				NewUntrustedInputMap("title"),
				NewUntrustedInputMap("body"),
			),
		),
		NewUntrustedInputMap("head_ref"),
	),
}

BuiltinUntrustedInputs is list of untrusted inputs. These inputs are detected as untrusted in `run:` scripts. See the URL for more details. - https://securitylab.github.com/research/github-actions-untrusted-input/ - https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks - https://github.com/github/codeql/blob/main/javascript/ql/src/experimental/Security/CWE-094/ExpressionInjection.ql

View Source
var OutdatedPopularActionSpecs = map[string]struct{}{}/* 154 elements not displayed */

OutdatedPopularActionSpecs is a spec set of known outdated popular actions. The word 'outdated' means that the runner used by the action is no longer available such as "node12", "node16".

View Source
var PopularActions = map[string]*ActionMetadata{}/* 247 elements not displayed */

PopularActions is data set of known popular actions. Keys are specs (owner/repo@ref) of actions and values are their metadata.

View Source
var SpecialFunctionNames = map[string][]string{"always": {"jobs.<job_id>.if", "jobs.<job_id>.steps.if", "jobs.<job_id>.snapshot.if"}, "cancelled": {"jobs.<job_id>.if", "jobs.<job_id>.steps.if", "jobs.<job_id>.snapshot.if"}, "failure": {"jobs.<job_id>.if", "jobs.<job_id>.steps.if", "jobs.<job_id>.snapshot.if"}, "hashfiles": {"jobs.<job_id>.steps.continue-on-error", "jobs.<job_id>.steps.env", "jobs.<job_id>.steps.if", "jobs.<job_id>.steps.name", "jobs.<job_id>.steps.run", "jobs.<job_id>.steps.timeout-minutes", "jobs.<job_id>.steps.with", "jobs.<job_id>.steps.working-directory", "jobs.<job_id>.snapshot.if"}, "success": {"jobs.<job_id>.if", "jobs.<job_id>.steps.if", "jobs.<job_id>.snapshot.if"}}

SpecialFunctionNames is a map from special function name to available workflow keys. Some functions are only available at specific positions. This variable is useful when you want to know which functions are special and what workflow keys support them.

This variable was generated from https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. See the script for more details: https://github.com/kjanat/actionlint/blob/HEAD/scripts/generate-availability/

Functions

func ContainsExpression

func ContainsExpression(s string) bool

ContainsExpression checks if the given string contains a ${{ }} placeholder or not. This function is identical to String.ContainsExpression method except for taking a standard string value.

func EqualTypes

func EqualTypes(l, r ExprType) bool

EqualTypes returns if the two types are equal.

func InlineSuppressibleRules added in v1.17.0

func InlineSuppressibleRules() []string

InlineSuppressibleRules returns the rule IDs accepted by inline directives and disallow-suppressions configuration. The returned slice is owned by the caller.

func LexExpression

func LexExpression(src string) ([]*Token, int, *ExprError)

LexExpression lexes the given string as expression syntax. The parameter must contain '}}' which represents end of expression. Otherwise this function will report an error that it encountered unexpected EOF.

func Parse

func Parse(b []byte) (*Workflow, []*Error)

Parse parses given source as byte sequence into workflow syntax tree. It returns all errors detected while parsing the input. It means that detecting one error does not stop parsing. Even if one or more errors are detected, parser will try to continue parsing and finding more errors.

func SARIFTemplate added in v1.14.0

func SARIFTemplate() string

SARIFTemplate returns the canonical Go template for SARIF output.

func VisitExprNode

func VisitExprNode(n ExprNode, f VisitExprNodeFunc)

VisitExprNode visits the given expression syntax tree with given function f.

func WorkflowKeyAvailability

func WorkflowKeyAvailability(key string) ([]string, []string)

WorkflowKeyAvailability returns contexts and special functions availability of the given workflow key. 1st return value indicates what contexts are available. Empty slice means any contexts are available. 2nd return value indicates what special functions are available. Empty slice means no special functions are available. The 'key' parameter should represents a workflow key like "jobs.<job_id>.concurrency".

This function was generated from https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability. See the script for more details: https://github.com/kjanat/actionlint/blob/HEAD/scripts/generate-availability/

Types

type ActionCompositeStep added in v1.13.0

type ActionCompositeStep struct {
	// Line is the line where the step starts in action.yaml.
	Line int `json:"line"`
	// Column is the column where the step starts in action.yaml.
	Column int `json:"column"`
	// IsMapping is whether the step is a mapping node. The runner requires every step to be a
	// mapping.
	IsMapping bool `json:"is_mapping"`
	// Keys is the key names of the step mapping in file order.
	Keys []string `json:"keys"`
	// If is the "if" key value when it is a string.
	If *ActionExprString `json:"if"`
	// Run is the "run" key value when it is a string. It is nil when the key is absent or its
	// value is not a string.
	Run *ActionExprString `json:"run"`
	// WorkingDirectory is the "working-directory" key value when it is a string.
	WorkingDirectory *ActionExprString `json:"working_directory"`
	// StepName is the "name" key value when it is a string.
	StepName *ActionExprString `json:"name"`
	// With holds each "with" input value that is a string.
	With []*ActionKeyValue `json:"with"`
	// Env holds each "env" variable value that is a string.
	Env []*ActionKeyValue `json:"env"`

	// Uses is the value of "uses" key in the step. It is nil when the key is absent or its value
	// is not a string.
	Uses *string `json:"uses"`
	// contains filtered or unexported fields
}

ActionCompositeStep is a step in "steps" section in "runs" section of action.yaml for a composite action. The runner only accepts a step which runs a script with "run" and "shell" keys, or a step which runs another action with "uses" key. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runssteps

func (*ActionCompositeStep) UnmarshalYAML added in v1.13.0

func (s *ActionCompositeStep) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ActionExprString added in v1.15.1

type ActionExprString struct {
	Value  string `json:"value"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
}

ActionExprString is a string value from action metadata that may contain ${{ }} expressions, together with the position of the value node in the metadata file.

type ActionKeyValue added in v1.15.1

type ActionKeyValue struct {
	Name  string           `json:"name"`
	Value ActionExprString `json:"value"`
}

ActionKeyValue is a named, positioned string in action metadata, used for input defaults and composite step "with" and "env" mappings.

type ActionMetadata

type ActionMetadata struct {

	// Name is "name" field of action.yaml.
	Name string `yaml:"name" json:"name"`
	// Description is "description" field of action.yaml.
	Description string `yaml:"description" json:"-"`
	// Inputs is "inputs" field of action.yaml.
	Inputs ActionMetadataInputs `yaml:"inputs" json:"inputs"`
	// Outputs is "outputs" field of action.yaml. Key is name of output. Description is omitted
	// since actionlint does not use it.
	Outputs ActionMetadataOutputs `yaml:"outputs" json:"outputs"`
	// SkipInputs is flag to specify behavior of inputs check. When it is true, inputs for this
	// action will not be checked.
	SkipInputs bool `yaml:"-" json:"skip_inputs"`
	// SkipOutputs is flag to specify a bit loose typing to outputs object. If it is set to
	// true, the outputs object accepts any properties along with strictly typed props.
	SkipOutputs bool `yaml:"-" json:"skip_outputs"`
	// Runs is "runs" field of action.yaml.
	Runs ActionMetadataRuns `yaml:"runs" json:"runs"`
	// Branding is "branding" field of action.yaml.
	Branding ActionMetadataBranding `yaml:"branding" json:"-"`
	// InputDefaults holds each string input default and its position in the metadata file.
	InputDefaults []*ActionKeyValue `yaml:"-" json:"-"`
	// contains filtered or unexported fields
}

ActionMetadata represents structure of action.yaml. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions

func (*ActionMetadata) Dir

func (md *ActionMetadata) Dir() string

Dir returns a directory path of the action.

func (*ActionMetadata) Path

func (md *ActionMetadata) Path() string

Path returns a file path of the action's metadata file.

func (*ActionMetadata) UnmarshalYAML added in v1.16.0

func (md *ActionMetadata) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler. In addition to the struct tags, it captures the value and position of each input's "default" so that ${{ }} expressions used there can be checked against the runner's input-default context.

type ActionMetadataBranding

type ActionMetadataBranding struct {
	Icon  string `yaml:"icon"`
	Color string `yaml:"color"`
}

ActionMetadataBranding is "branding" section of action.yaml. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#branding

func (*ActionMetadataBranding) UnmarshalYAML added in v1.17.0

func (b *ActionMetadataBranding) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ActionMetadataInput

type ActionMetadataInput struct {
	// Name is a name of this input.
	Name string `json:"name"`
	// Required is true when this input is mandatory to run the action.
	Required bool `json:"required"`
	// Deprecated is true when this input is marked as deprecated.
	Deprecated bool `json:"deprecated"`
	// DeprecationMessage is a deprecation message for the deprecated input.
	DeprecationMessage string `json:"deprecation-message"`
}

ActionMetadataInput is input metadata in "inputs" section in action.yml metadata file. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs

type ActionMetadataInputs

type ActionMetadataInputs map[string]*ActionMetadataInput

ActionMetadataInputs is a map from input ID to its metadata. Keys are in lower case since input names are case-insensitive. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs

func (*ActionMetadataInputs) UnmarshalYAML

func (inputs *ActionMetadataInputs) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ActionMetadataOutput

type ActionMetadataOutput struct {
	Name string `json:"name"`
}

ActionMetadataOutput is output metadata in "outputs" section in action.yml metadata file. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions

type ActionMetadataOutputs

type ActionMetadataOutputs map[string]*ActionMetadataOutput

ActionMetadataOutputs is a map from output ID to its metadata. Keys are in lower case since output names are case-insensitive. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions

func (*ActionMetadataOutputs) UnmarshalYAML

func (inputs *ActionMetadataOutputs) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ActionMetadataRuns

type ActionMetadataRuns struct {
	// Plugin is the runner-internal plugin action entrypoint.
	Plugin string `yaml:"plugin" json:"plugin,omitempty"`
	// Using is `using` configuration of action.yaml. It defines what runner is used for the action.
	Using string `yaml:"using" json:"using"`
	// Main is `main` configuration of action.yaml for JavaScript action.
	Main string `yaml:"main" json:"main"`
	// Pre is `pre` configuration of action.yaml for JavaScript action.
	Pre string `yaml:"pre" json:"pre"`
	// PreIf is `pre-if` configuration of action.yaml for JavaScript action.
	PreIf string `yaml:"pre-if" json:"pre-if"`
	// Post is `post` configuration of action.yaml for JavaScript action.
	Post string `yaml:"post" json:"post"`
	// PostIf is `post-if` configuration of action.yaml for JavaScript action.
	PostIf string `yaml:"post-if" json:"post-if"`
	// Steps is `steps` configuration of action.yaml for Composite action.
	Steps actionCompositeSteps `yaml:"steps" json:"steps"`
	// Image is `image` of action.yaml for Docker action.
	Image string `yaml:"image" json:"image"`
	// PreEntrypoint is `pre-entrypoint` of action.yaml for Docker action.
	PreEntrypoint string `yaml:"pre-entrypoint" json:"pre-entrypoint"`
	// Entrypoint is `entrypoint` of action.yaml for Docker action.
	Entrypoint string `yaml:"entrypoint" json:"entrypoint"`
	// PostEntrypoint is `post-entrypoint` of action.yaml for Docker action.
	PostEntrypoint string `yaml:"post-entrypoint" json:"post-entrypoint"`
	// Args is `args` of action.yaml for Docker action.
	Args []any `yaml:"args" json:"args"`
	// Env is `env` of action.yaml for Docker action.
	Env map[string]any `yaml:"env" json:"env"`
}

ActionMetadataRuns is "runs" section of action.yaml. It defines how the action is run. https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs

func (*ActionMetadataRuns) UnmarshalYAML added in v1.17.0

func (r *ActionMetadataRuns) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ActionRuntime added in v1.16.0

type ActionRuntime struct {
	Removed        bool
	Deprecated     bool
	DeprecationURL string
	RemovalDate    string
}

ActionRuntime describes a JavaScript runtime accepted by the runner's action metadata parser. Removed means the runner no longer bundles its executable; the metadata value remains accepted.

type AnyType

type AnyType struct{}

AnyType represents type which can be any type. It also indicates that a value of the type cannot be type-checked since it's type cannot be known statically.

func (AnyType) Assignable

func (ty AnyType) Assignable(_ ExprType) bool

Assignable returns if other type can be assignable to the type.

func (AnyType) DeepCopy

func (ty AnyType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (AnyType) Merge

func (ty AnyType) Merge(other ExprType) ExprType

Merge merges other type into this type. When other type conflicts with this type, the merged result is any type as fallback.

func (AnyType) String

func (ty AnyType) String() string

type ArrayDerefNode

type ArrayDerefNode struct {
	// Receiver is an expression at receiver of array element dereference.
	Receiver ExprNode
}

ArrayDerefNode represents elements dereference of arrays like '*' in 'foo.bar.*.piyo'.

func (ArrayDerefNode) Token

func (n ArrayDerefNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type ArrayType

type ArrayType struct {
	// Elem is type of element of the array.
	Elem ExprType
	// Deref is true when this type was derived from object filtering syntax (foo.*).
	Deref bool
}

ArrayType is type for arrays.

func (*ArrayType) Assignable

func (ty *ArrayType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type.

func (*ArrayType) DeepCopy

func (ty *ArrayType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (*ArrayType) Merge

func (ty *ArrayType) Merge(other ExprType) ExprType

Merge merges two object types into one. When other object has unknown props, they are merged into current object. When both have same property, when they are assignable, it remains as-is. Otherwise, the property falls back to any type.

func (*ArrayType) String

func (ty *ArrayType) String() string

type Bool

type Bool struct {
	// Value is a raw value of the bool string.
	Value bool
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Bool represents generic boolean value in YAML file with position.

func (*Bool) String

func (b *Bool) String() string

type BoolNode

type BoolNode struct {
	// Value is value of the boolean literal.
	Value bool
	// contains filtered or unexported fields
}

BoolNode is node for boolean literal, true or false.

func (*BoolNode) Token

func (n *BoolNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type BoolType

type BoolType struct{}

BoolType is type for boolean values.

func (BoolType) Assignable

func (ty BoolType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type.

func (BoolType) DeepCopy

func (ty BoolType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (BoolType) Merge

func (ty BoolType) Merge(other ExprType) ExprType

Merge merges other type into this type. When other type conflicts with this type, the merged result is any type as fallback.

func (BoolType) String

func (ty BoolType) String() string

type CacheMode added in v1.17.0

type CacheMode struct {
	Kind CacheModeKind
	Pos  *Pos
}

CacheMode is an explicit cache-mode declaration. An omitted declaration is a nil pointer.

type CacheModeKind added in v1.17.0

type CacheModeKind uint8

CacheModeKind identifies the cache access granted to a workflow or job.

const (
	// CacheModeInvalid represents an invalid declaration, distinct from an omitted one.
	CacheModeInvalid CacheModeKind = iota
	// CacheModeNone prevents restores and saves.
	CacheModeNone
	// CacheModeRead allows restores only.
	CacheModeRead
	// CacheModeWrite allows restores and saves.
	CacheModeWrite
	// CacheModeWriteOnly allows saves only.
	CacheModeWriteOnly
)

func (CacheModeKind) String added in v1.17.0

func (k CacheModeKind) String() string

String returns the workflow spelling of the cache mode.

type ColorOptionKind

type ColorOptionKind int

ColorOptionKind is kind of colorful output behavior.

const (
	// ColorOptionKindAuto is kind to determine to colorize errors output automatically. It is
	// determined based on pty and $NO_COLOR environment variable. See document of fatih/color
	// for more details.
	ColorOptionKindAuto ColorOptionKind = iota
	// ColorOptionKindAlways is kind to always colorize errors output.
	ColorOptionKindAlways
	// ColorOptionKindNever is kind never to colorize errors output.
	ColorOptionKindNever
)

type Command

type Command struct {
	// Stdin is a reader to read input from stdin
	Stdin io.Reader
	// Stdout is a writer to write output to stdout
	Stdout io.Writer
	// Stderr is a writer to write output to stderr
	Stderr io.Writer
}

Command represents entire actionlint command. Given stdin/stdout/stderr are used for input/output.

Example
package main

import (
	"bytes"
	"fmt"
	"os"
	"path/filepath"

	"actionlint.kjanat.dev"
)

func main() {
	// Write command output to this buffer
	var output bytes.Buffer

	// Create command instance populating stdin/stdout/stderr
	cmd := actionlint.Command{
		Stdin:  os.Stdin,
		Stdout: &output,
		Stderr: &output,
	}

	// Run the command end-to-end. Note that given args should contain program name
	workflow := filepath.Join(".github", "workflows", "release.yml")
	status := cmd.Main([]string{"actionlint", "-shellcheck=", "-pyflakes=", workflow})

	fmt.Println("Exited with status", status)

	if status != 0 {
		panic("actionlint command failed: " + output.String())
	}
}
Output:
Exited with status 0

func (*Command) Main

func (cmd *Command) Main(args []string) int

Main is main function of actionlint. It takes command line arguments as string slice and returns exit status. The args should be entire arguments including the program name, usually given via os.Args.

type CompareOpNode

type CompareOpNode struct {
	// Kind is a kind of this expression to show which operator is used.
	Kind CompareOpNodeKind
	// Left is an expression for left hand side of the binary operator.
	Left ExprNode
	// Right is an expression for right hand side of the binary operator.
	Right ExprNode
}

CompareOpNode is node for binary expression to compare values; ==, !=, <, <=, > or >=.

func (*CompareOpNode) Token

func (n *CompareOpNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type CompareOpNodeKind

type CompareOpNodeKind int

CompareOpNodeKind is a kind of compare operators; ==, !=, <, <=, >, >=.

const (
	// CompareOpNodeKindInvalid is invalid and initial value of CompareOpNodeKind values.
	CompareOpNodeKindInvalid CompareOpNodeKind = iota
	// CompareOpNodeKindLess is kind for < operator.
	CompareOpNodeKindLess
	// CompareOpNodeKindLessEq is kind for <= operator.
	CompareOpNodeKindLessEq
	// CompareOpNodeKindGreater is kind for > operator.
	CompareOpNodeKindGreater
	// CompareOpNodeKindGreaterEq is kind for >= operator.
	CompareOpNodeKindGreaterEq
	// CompareOpNodeKindEq is kind for == operator.
	CompareOpNodeKindEq
	// CompareOpNodeKindNotEq is kind for != operator.
	CompareOpNodeKindNotEq
)

func (CompareOpNodeKind) IsEqualityOp

func (kind CompareOpNodeKind) IsEqualityOp() bool

IsEqualityOp returns true when it represents == or != operator.

func (CompareOpNodeKind) String

func (kind CompareOpNodeKind) String() string

type Concurrency

type Concurrency struct {
	// Expression supplies a group string or complete concurrency mapping.
	Expression *String
	// Group is name of the concurrency group.
	Group *String
	// CancelInProgress is a flag that shows if canceling this workflow cancels other jobs in progress.
	CancelInProgress *Bool
	// Queue is the queue strategy for pending workflow runs. Valid values are "single" (default) and "max".
	Queue *String
	// Pos is a position in source.
	Pos *Pos
}

Concurrency is a configuration of concurrency of the workflow. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency

type Config

type Config struct {
	// SelfHostedRunner configures extra labels accepted for self-hosted runners.
	//
	// Add your labels under `labels`, for example `{labels: [linux.2xlarge]}`.
	SelfHostedRunner SelfHostedRunnerConfig `yaml:"self-hosted-runner" jsonschema:"nullable"`
	// ConfigVariables lists configuration variable names available to the checked workflows through `vars`.
	//
	// Omit this key or use `null` to disable variable-name checking. Use `[]` to allow no variables.
	// A list such as `[DEFAULT_RUNNER, ENVIRONMENT_STAGE]` reports names outside that list as undefined.
	ConfigVariables []string `yaml:"config-variables" jsonschema:"nullable"`
	// ConfigSecrets lists secret names available to the checked workflows through `secrets`.
	//
	// Omit this key or use `null` to disable secret-name checking. Use `[]` to allow only built-in
	// secrets and secrets declared in `on.workflow_call.secrets`. A list such as `[DEPLOY_TOKEN, API_KEY]`
	// also allows those names; other names are reported as undefined. Matching is case-insensitive.
	//
	// `GITHUB_TOKEN`, `ACTIONS_STEP_DEBUG`, and `ACTIONS_RUNNER_DEBUG` are always allowed.
	// List names only, never secret values.
	ConfigSecrets []string `yaml:"config-secrets" jsonschema:"nullable"`
	// Paths applies configuration to workflow files matching a glob pattern.
	//
	// Keys are paths relative to the repository root, using `/` separators and doublestar glob syntax,
	// for example `.github/workflows/**/*.yaml`. All matching entries apply. Each entry can set `ignore`.
	Paths map[string]PathConfig `yaml:"paths" jsonschema:"nullable"`
	// AssumeDefaultPermissions selects the repository's assumed default token permissions when checking
	// reusable workflow calls whose calling job and workflow both omit `permissions:`.
	//
	// `restricted` (the default) grants read access to `contents` and `packages` only.
	// `permissive` assumes read/write access, except `id-token`, which still requires an explicit grant.
	// Omit this key or use `null` to assume `restricted`.
	AssumeDefaultPermissions DefaultPermissionsAssumption `yaml:"assume-default-permissions" jsonschema:"nullable"`
	// Policy configures cache safety checks and repository conventions, such as pinned actions and job timeouts.
	//
	// Cache policies default to true; other policies are opt-in. Set individual keys to override their
	// defaults. Omit the mapping or use `{}` or `null` to keep defaults. Syntax checks always run.
	Policy Policy `yaml:"policy" jsonschema:"nullable"`
}

Config configures validation of GitHub Actions workflows for this repository.

Declare custom runner labels and available variable or secret names, suppress selected diagnostics by file path, choose assumed token permissions, and enable repository policy checks. Save as `.github/actionlint.yaml` or `.github/actionlint.yml`, or select a file with `-config-file`. Every setting is optional; normal workflow correctness checks run without a configuration file.

func ParseConfig

func ParseConfig(b []byte) (*Config, error)

ParseConfig parses the given bytes as an actionlint config file. When deserializing the YAML file or the config validation fails, this function returns an error.

func ReadConfigFile

func ReadConfigFile(path string) (*Config, error)

ReadConfigFile reads actionlint config file (actionlint.yaml) from the given file path.

func (*Config) PathConfigs

func (cfg *Config) PathConfigs(path string) []PathConfig

PathConfigs returns a list of all PathConfig values matching to the given file path. The path must be relative to the root of the project.

func (*Config) RequiredActions added in v1.13.0

func (cfg *Config) RequiredActions() []string

RequiredActions returns the actions which every workflow must use following the "required-actions" policy. It returns nil when the receiver is nil or when the key is not set.

func (*Config) RequiresCommitHash added in v1.13.0

func (cfg *Config) RequiresCommitHash() bool

RequiresCommitHash returns whether the "require-commit-hash" policy is enabled. It returns false when the receiver is nil or when the key is not set.

func (*Config) RequiresJobTimeout added in v1.13.0

func (cfg *Config) RequiresJobTimeout() *JobTimeoutPolicy

RequiresJobTimeout returns the "require-job-timeout" policy. It returns nil when the receiver is nil or when the key is not set.

func (*Config) RequiresPermissions added in v1.16.0

func (cfg *Config) RequiresPermissions() *PermissionsPolicy

RequiresPermissions returns the "require-permissions" policy, or nil for an unset key or nil receiver.

type Container

type Container struct {
	// Expression supplies an image string or complete container mapping.
	Expression *String
	// Image is specification of Docker image.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerimage
	Image *String
	// Credentials is credentials configuration of the Docker container.
	Credentials *Credentials
	// Env is environment variables setup in the container.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerenv
	Env *Env
	// Ports is list of port number mappings of the container.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainerports
	Ports []*String
	// PortsExpression supplies the complete ports sequence.
	PortsExpression *String
	// Volumes are list of volumes to be mounted to the container.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes
	Volumes []*String
	// VolumesExpression supplies the complete volumes sequence.
	VolumesExpression *String
	// Options is options string to run the container.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontaineroptions
	Options *String
	// Command overrides Docker image's default command for service containers.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservicesservice_idcommand
	Command *String
	// Entrypoint overrides Docker image's default entrypoint for service containers.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservicesservice_identrypoint
	Entrypoint *String
	// Pos is a position in source.
	Pos *Pos
}

Container is configuration of how to run the container. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainer

type Credentials

type Credentials struct {
	// Username is username for authentication.
	Username *String
	// Password is password for authentication.
	Password *String
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Credentials is credentials configuration. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontainercredentials

type DefaultPermissionsAssumption added in v1.13.0

type DefaultPermissionsAssumption uint8

DefaultPermissionsAssumption is an assumption about the repository's "Workflow permissions" setting, which actionlint cannot read from a workflow file.

const (
	// DefaultPermissionsAssumptionUnset means the "assume-default-permissions" key was not set.
	DefaultPermissionsAssumptionUnset DefaultPermissionsAssumption = iota
	// DefaultPermissionsAssumptionRestricted assumes GitHub's restricted default token, which grants read
	// access to "contents" and "packages" and nothing else.
	DefaultPermissionsAssumptionRestricted
	// DefaultPermissionsAssumptionPermissive assumes GitHub's permissive default token.
	DefaultPermissionsAssumptionPermissive
)

func (*DefaultPermissionsAssumption) UnmarshalYAML added in v1.13.0

func (a *DefaultPermissionsAssumption) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type Defaults

type Defaults struct {
	// Run is configuration of how to run shell.
	Run *DefaultsRun
	// Pos is a position in source.
	Pos *Pos
}

Defaults is set of default configurations to run shell. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#defaults

type DefaultsRun

type DefaultsRun struct {
	// Expression supplies the complete run defaults mapping.
	Expression *String
	// Shell is shell name to be run.
	Shell *String
	// WorkingDirectory is a default working directory path.
	WorkingDirectory *String
	// Pos is a position in source.
	Pos *Pos
}

DefaultsRun is configuration that shell is how to be run. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#defaultsrun

type DispatchInput

type DispatchInput struct {
	// Name is a name of input value specified on dispatching workflow manually.
	Name *String
	// Description is a description of input value specified on dispatching workflow manually.
	Description *String
	// Required is a flag to show if this input is mandatory or not on dispatching workflow manually.
	Required *Bool
	// Default is a default value of input value on dispatching workflow manually.
	Default *String
	// Type is a type of the input
	// https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch
	Type WorkflowDispatchEventInputType
	// Options is list of options of choice type
	Options []*String
}

DispatchInput is input specified on dispatching workflow manually. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch

type Env

type Env struct {
	// Vars is mapping from env var name to env var value.
	Vars map[string]*EnvVar
	// Expression is an expression string which contains ${{ ... }}. When this value is not empty,
	// Vars should be nil.
	Expression *String
}

Env represents set of environment variables.

type EnvVar

type EnvVar struct {
	// Name is name of the environment variable.
	Name *String
	// Value is string value of the environment variable.
	Value *String
}

EnvVar represents key-value of environment variable setup.

type Environment

type Environment struct {
	// Expression supplies an environment name or complete environment mapping.
	Expression *String
	// Name is a name of environment which the workflow uses.
	Name *String
	// URL is the URL mapped to 'environment_url' in the deployments API. Empty value means no value was specified.
	URL *String
	// Deployment is whether GitHub should create a deployment for this job. false skips auto-deployment while still applying environment protection rules and secrets.
	Deployment *Bool
	// Pos is a position in source.
	Pos *Pos
}

Environment is a configuration of environment. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idenvironment

type Error

type Error struct {
	// Message is an error message.
	Message string
	// Filepath is a file path where the error occurred.
	Filepath string
	// Line is a line number where the error occurred. This value is 1-based.
	Line int
	// Column is a column number where the error occurred. This value is 1-based.
	Column int
	// Kind is a string to represent kind of the error. Usually rule name which found the error.
	Kind string
	// contains filtered or unexported fields
}

Error represents an error detected by actionlint rules

func (*Error) Error

func (e *Error) Error() string

Error returns summary of the error as string.

func (*Error) GetTemplateFields

func (e *Error) GetTemplateFields(source []byte) *ErrorTemplateFields

GetTemplateFields fields for formatting this error with Go template.

func (*Error) PrettyPrint

func (e *Error) PrettyPrint(w io.Writer, source []byte)

PrettyPrint prints the error with user-friendly way. It prints file name, source position, error message with colorful output and source snippet with indicator. When nil is set to source, no source snippet is not printed. To disable colorful output, set true to fatih/color.NoColor.

func (*Error) String

func (e *Error) String() string

type ErrorFormatter

type ErrorFormatter struct {
	// contains filtered or unexported fields
}

ErrorFormatter is a formatter to format a slice of ErrorTemplateFields. It is used for formatting error messages with -format option.

Example
package main

import (
	"os"

	"actionlint.kjanat.dev"
)

func main() {
	// Errors returned from Linter methods
	errs := []*actionlint.Error{
		{
			Message:  "error message 1",
			Filepath: "foo.yaml",
			Line:     1,
			Column:   4,
			Kind:     "rule1",
		},
		{
			Message:  "error message 2",
			Filepath: "foo.yaml",
			Line:     3,
			Column:   1,
			Kind:     "rule2",
		},
	}

	// Create ErrorFormatter instance with template
	f, err := actionlint.NewErrorFormatter(`{{range $ := .}}{{$.Filepath}}:{{$.Line}}:{{$.Column}}: {{$.Message}}\n{{end}}`)
	if err != nil {
		// Some error happened while creating the formatter (e.g. syntax error)
		panic(err)
	}

	src := `on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo
`

	// Prints all errors to stdout following the template
	if err := f.PrintErrors(os.Stdout, errs, []byte(src)); err != nil {
		panic(err)
	}

}
Output:
foo.yaml:1:4: error message 1
foo.yaml:3:1: error message 2

func NewErrorFormatter

func NewErrorFormatter(format string) (*ErrorFormatter, error)

NewErrorFormatter creates new ErrorFormatter instance. Given format must contain at least one {{ }} placeholder. Escaped characters like \n in the format string are unescaped.

func (*ErrorFormatter) Print

func (f *ErrorFormatter) Print(out io.Writer, t []*ErrorTemplateFields) error

Print formats the slice of template fields and prints it with given writer.

func (*ErrorFormatter) PrintErrors

func (f *ErrorFormatter) PrintErrors(out io.Writer, errs []*Error, src []byte) error

PrintErrors prints the errors after formatting them with template.

func (*ErrorFormatter) RegisterRule

func (f *ErrorFormatter) RegisterRule(r Rule)

RegisterRule registers the rule. Registered rules are used to get description and index of error kinds when you use `kindDescription` or `kindIndex` functions in an error format template. This method can be called multiple times safely in parallel.

type ErrorTemplateFields

type ErrorTemplateFields struct {
	// Message is error message body.
	Message string `json:"message"`
	// Filepath is a canonical relative file path. This is empty when input was read from stdin.
	// When encoding into JSON, this field may be omitted when the file path is empty.
	Filepath string `json:"filepath,omitempty"`
	// Line is a line number of error position.
	Line int `json:"line"`
	// Column is a column number of error position.
	Column int `json:"column"`
	// Kind is a rule name the error belongs to.
	Kind string `json:"kind"`
	// Snippet is a code snippet and indicator to indicate where the error occurred.
	// When encoding into JSON, this field may be omitted when the snippet is empty.
	Snippet string `json:"snippet,omitempty"`
	// EndColumn is a column number where the error indicator (^~~~~~~) ends. When no indicator
	// can be shown, EndColumn is equal to Column.
	EndColumn int `json:"end_column"`
}

ErrorTemplateFields holds all fields to format one error message.

type Event

type Event interface {
	// EventName returns name of the event to trigger this workflow.
	EventName() string
}

Event interface represents workflow events in 'on' section

type Exec

type Exec interface {
	// Kind returns kind of the step execution.
	Kind() ExecKind
}

Exec is an interface how the step is executed. Step in workflow runs either an action or a script

type ExecAction

type ExecAction struct {
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses
	// Uses is nil when its value could not be parsed as a nonempty string.
	Uses *String
	// Inputs represents inputs to the action to execute in 'with' section. Keys are in lower case since they are case-insensitive.
	Inputs map[string]*Input
	// InputsExpression supplies the complete action inputs mapping.
	InputsExpression *String
	// Entrypoint represents optional 'entrypoint' field in 'with' section. Nil field means nothing specified
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithentrypoint
	Entrypoint *String
	// Args represents optional 'args' field in 'with' section. Nil field means nothing specified
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs
	Args *String
}

ExecAction is configuration how to run action at the step. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses

func (*ExecAction) Kind

func (e *ExecAction) Kind() ExecKind

Kind returns kind of the step execution.

type ExecCancel

type ExecCancel struct {
	// Name is the ID of the background step to cancel, given by the 'cancel' field. The 'cancel' step
	// targets a single background step by its ID.
	Name *String
}

ExecCancel is configuration of a step that cancels a running background step. It corresponds to the 'cancel' step. https://github.blog/changelog/2026-06-25-actions-steps-can-now-be-run-in-parallel/

func (*ExecCancel) Kind

func (e *ExecCancel) Kind() ExecKind

Kind returns kind of the step execution.

type ExecKind

type ExecKind uint8

ExecKind is kind of how the step is executed. A step runs some action or runs some shell script.

const (
	// ExecKindAction is kind for step to run action
	ExecKindAction ExecKind = iota
	// ExecKindRun is kind for step to run shell script
	ExecKindRun
	// ExecKindWait is kind for step to wait for background steps ('wait' or 'wait-all')
	ExecKindWait
	// ExecKindCancel is kind for step to cancel background steps ('cancel')
	ExecKindCancel
	// ExecKindParallel is kind for step to run a group of steps in parallel ('parallel')
	ExecKindParallel
)

type ExecParallel

type ExecParallel struct {
	// Steps is the group of steps to run in parallel, given by the 'parallel' field.
	Steps []*Step
}

ExecParallel is configuration of a step that runs a group of steps in parallel. It corresponds to the 'parallel' step. https://github.blog/changelog/2026-06-25-actions-steps-can-now-be-run-in-parallel/

func (*ExecParallel) Kind

func (e *ExecParallel) Kind() ExecKind

Kind returns kind of the step execution.

type ExecRun

type ExecRun struct {
	// Run is script to run.
	Run *String

	// Shell represents optional 'shell' field. Nil means nothing specified.
	Shell *String
	// WorkingDirectory represents optional 'working-directory' field. Nil means nothing specified.
	WorkingDirectory *String
	// RunPos is position of 'run' section
	RunPos *Pos
	// contains filtered or unexported fields
}

ExecRun is configuration how to run shell script at the step. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsrun

func (*ExecRun) Kind

func (e *ExecRun) Kind() ExecKind

Kind returns kind of the step execution.

type ExecWait

type ExecWait struct {
	// Names is the list of background step IDs to wait for, given by the 'wait' field. It is nil when
	// 'wait-all' is used instead.
	Names []*String
	// All is true when the step waits for all preceding background steps via the 'wait-all' field.
	All bool
	// AllPos is the position of the 'wait-all' field. It is nil when 'wait' is used instead.
	AllPos *Pos
}

ExecWait is configuration of a step that waits for background steps to complete. It corresponds to the 'wait' and 'wait-all' steps. https://github.blog/changelog/2026-06-25-actions-steps-can-now-be-run-in-parallel/

func (*ExecWait) Kind

func (e *ExecWait) Kind() ExecKind

Kind returns kind of the step execution.

type ExprError

type ExprError struct {
	// Message is an error message
	Message string
	// Offset is byte offset position which caused the error
	Offset int
	// Offset is line number position which caused the error. Note that this value is 1-based.
	Line int
	// Column is column number position which caused the error. Note that this value is 1-based.
	Column int
}

ExprError is an error type caused by lexing/parsing expression syntax. For more details, see https://docs.github.com/en/actions/learn-github-actions/expressions

func (*ExprError) Error

func (e *ExprError) Error() string

func (*ExprError) String

func (e *ExprError) String() string

type ExprLexer

type ExprLexer struct {
	// contains filtered or unexported fields
}

ExprLexer is a struct to lex expression syntax. To know the syntax, see https://docs.github.com/en/actions/learn-github-actions/expressions

func NewExprLexer

func NewExprLexer(src string) *ExprLexer

NewExprLexer makes new ExprLexer instance.

func (*ExprLexer) Err

func (lex *ExprLexer) Err() *ExprError

Err returns an error while lexing. When multiple errors occur, the first one is returned.

func (*ExprLexer) Next

func (lex *ExprLexer) Next() *Token

Next lexes next token to lex input incrementally. Lexer must be initialized with Init() method before the first call of this method. This method is stateful. Lexer advances offset by lexing token. To get the offset, use Offset() method.

func (*ExprLexer) Offset

func (lex *ExprLexer) Offset() int

Offset returns the current offset (scanning position).

type ExprNode

type ExprNode interface {
	// Token returns the first token of the node. This method is useful to get position of this node.
	Token() *Token
}

ExprNode is a node of expression syntax tree. To know the syntax, see https://docs.github.com/en/actions/learn-github-actions/expressions

type ExprParser

type ExprParser struct {
	// contains filtered or unexported fields
}

ExprParser is a parser for expression syntax. To know the details, see https://docs.github.com/en/actions/learn-github-actions/expressions

func NewExprParser

func NewExprParser() *ExprParser

NewExprParser creates new ExprParser instance.

func (*ExprParser) Err

func (p *ExprParser) Err() *ExprError

Err returns an error which was caused while previous parsing.

func (*ExprParser) Parse

func (p *ExprParser) Parse(l *ExprLexer) (ExprNode, *ExprError)

Parse parses token sequence lexed by a given lexer into syntax tree.

type ExprSemanticsChecker

type ExprSemanticsChecker struct {
	// contains filtered or unexported fields
}

ExprSemanticsChecker is a semantics checker for expression syntax. It checks types of values in given expression syntax tree. It additionally checks other semantics like arguments of format() built-in function. To know the details of the syntax, see

- https://docs.github.com/en/actions/learn-github-actions/contexts - https://docs.github.com/en/actions/learn-github-actions/expressions

func NewExprSemanticsChecker

func NewExprSemanticsChecker(checkUntrustedInput bool, cfg *Config) *ExprSemanticsChecker

NewExprSemanticsChecker creates new ExprSemanticsChecker instance. When checkUntrustedInput is set to true, the checker will make use of possibly untrusted inputs error. The cfg parameter is the user configuration used by the config-driven checks. It may be nil.

func (*ExprSemanticsChecker) Check

func (sema *ExprSemanticsChecker) Check(expr ExprNode) (ExprType, []*ExprError)

Check checks semantics of given expression syntax tree. It returns the type of the expression as the first return value when the check was successfully done. And it returns all errors found while checking the expression as the second return value.

func (*ExprSemanticsChecker) IsConstant

func (sema *ExprSemanticsChecker) IsConstant(expr ExprNode) bool

IsConstant returns the given expression is a constant. For example the following expressions are constants.

  • 1 == 2
  • (!true && 'foo') || 'bar'
  • startsWith('foobar', 'foo')
  • format('{} + {} = {}', 1, 2, 3)

func (*ExprSemanticsChecker) SetContextAvailability

func (sema *ExprSemanticsChecker) SetContextAvailability(avail []string)

SetContextAvailability sets available context names while semantics checks. Some contexts limit where they can be used. https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

Elements of 'avail' parameter must be in lower case to check context names in case-insensitive.

If this method is not called before checks, ExprSemanticsChecker considers any contexts are available by default. Available contexts for workflow keys can be obtained from actionlint.ContextAvailability.

func (*ExprSemanticsChecker) SetSpecialFunctionAvailability

func (sema *ExprSemanticsChecker) SetSpecialFunctionAvailability(avail []string)

SetSpecialFunctionAvailability sets names of available special functions while semantics checks. Some functions limit where they can be used. https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

Elements of 'avail' parameter must be in lower case to check function names in case-insensitive.

If this method is not called before checks, ExprSemanticsChecker considers no special function is allowed by default. Allowed functions can be obtained from actionlint.SpecialFunctionNames global constant.

Available function names for workflow keys can be obtained from actionlint.ContextAvailability.

func (*ExprSemanticsChecker) SetWorkflowKeyAvailability added in v1.17.0

func (sema *ExprSemanticsChecker) SetWorkflowKeyAvailability(key string)

SetWorkflowKeyAvailability selects workflow contexts, special functions, and position-specific signatures. Job conditions allow job arguments to success and failure; step and snapshot conditions require zero arguments.

func (*ExprSemanticsChecker) UpdateDispatchInputs

func (sema *ExprSemanticsChecker) UpdateDispatchInputs(ty *ObjectType)

UpdateDispatchInputs updates 'github.event.inputs' and 'inputs' objects to given object type. https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows

func (*ExprSemanticsChecker) UpdateInputs

func (sema *ExprSemanticsChecker) UpdateInputs(ty *ObjectType)

UpdateInputs updates 'inputs' context object to given object type.

func (*ExprSemanticsChecker) UpdateJobs

func (sema *ExprSemanticsChecker) UpdateJobs(ty *ObjectType)

UpdateJobs updates 'jobs' context object to given object type.

func (*ExprSemanticsChecker) UpdateMatrix

func (sema *ExprSemanticsChecker) UpdateMatrix(ty *ObjectType)

UpdateMatrix updates matrix object to given object type. Since matrix values change according to 'matrix' section of job configuration, the type needs to be updated.

func (*ExprSemanticsChecker) UpdateNeeds

func (sema *ExprSemanticsChecker) UpdateNeeds(ty *ObjectType)

UpdateNeeds updates 'needs' context object to given object type.

func (*ExprSemanticsChecker) UpdateSecrets

func (sema *ExprSemanticsChecker) UpdateSecrets(ty *ObjectType)

UpdateSecrets updates 'secrets' context object to given object type. The strictness of the given type is preserved, so an open type keeps allowing unknown secret names.

func (*ExprSemanticsChecker) UpdateSteps

func (sema *ExprSemanticsChecker) UpdateSteps(ty *ObjectType)

UpdateSteps updates 'steps' context object to given object type.

type ExprType

type ExprType interface {
	// String returns string representation of the type.
	String() string
	// Assignable returns if other type can be assignable to the type.
	Assignable(other ExprType) bool
	// Merge merges other type into this type. When other type conflicts with this type, the merged
	// result is any type as fallback.
	Merge(other ExprType) ExprType
	// DeepCopy duplicates itself. All its child types are copied recursively.
	DeepCopy() ExprType
}

ExprType is interface for types of values in expression.

type Float

type Float struct {
	// Value is a raw value of the float string.
	Value float64
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Float represents generic float value in YAML file with position.

type FloatNode

type FloatNode struct {
	// Value is value of the float literal.
	Value float64
	// contains filtered or unexported fields
}

FloatNode is node for float literal.

func (*FloatNode) Token

func (n *FloatNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type FuncCallNode

type FuncCallNode struct {
	// Callee is a name of called function. This is string value because currently only built-in
	// functions can be called.
	Callee string
	// Args is arguments of the function call.
	Args []ExprNode
	// contains filtered or unexported fields
}

FuncCallNode represents function call in expression. Note that currently only calling builtin functions is supported.

func (*FuncCallNode) Token

func (n *FuncCallNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type FuncSignature

type FuncSignature struct {
	// Name is a name of the function.
	Name string
	// Ret is a return type of the function.
	Ret ExprType
	// Params is a list of parameter types of the function. The final element of this list might
	// be repeated as variable length arguments.
	Params []ExprType
	// VariableLengthParams is a flag to handle variable length parameters. When this flag is set to
	// true, it means that the last type of params might be specified multiple times (including zero
	// times). Setting true implies length of Params is more than 0.
	VariableLengthParams bool
	// IsConstFunc is true when the function returns a constant when all parameters are constants.
	IsConstFunc bool
}

FuncSignature is a signature of function, which holds return and arguments types.

func (*FuncSignature) String

func (sig *FuncSignature) String() string

type IgnorePatterns

type IgnorePatterns []*regexp.Regexp

IgnorePatterns is a list of regular expressions. These patterns are used for filtering errors by matching the error messages.

func (IgnorePatterns) Match

func (pats IgnorePatterns) Match(err *Error) bool

Match returns whether the given error should be ignored due to the "ignore" configuration.

func (*IgnorePatterns) UnmarshalYAML

func (pats *IgnorePatterns) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ImageVersionEvent

type ImageVersionEvent struct {
	// Types filters image version activity to created, ready, or deleted events.
	Types []*String
	// Names is a list of names which match to the created image names.
	Names []*String
	// Versions is a list of names which match to the created image versions. Glob patterns are available.
	Versions []*String
	// Pos is a position in source.
	Pos *Pos
}

ImageVersionEvent is image_version event configuration. https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#image_version

func (*ImageVersionEvent) EventName

func (e *ImageVersionEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type IndexAccessNode

type IndexAccessNode struct {
	// Operand is an expression at operand of index access, which should be array or object.
	Operand ExprNode
	// Index is an expression at index, which should be integer or string.
	Index ExprNode
}

IndexAccessNode is node for index access, which represents dynamic object property access or array index access.

func (*IndexAccessNode) Token

func (n *IndexAccessNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type Input

type Input struct {
	// Name is a name of the input.
	Name *String
	// Value is a value of the input.
	Value *String
}

Input is an input field for running an action. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswith

type Int

type Int struct {
	// Value is a raw value of the integer string.
	Value int
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Int represents generic integer value in YAML file with position.

type IntNode

type IntNode struct {
	// Value is value of the integer literal.
	Value int
	// contains filtered or unexported fields
}

IntNode is node for integer literal.

func (*IntNode) Token

func (n *IntNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type InvalidGlobPatternError

type InvalidGlobPatternError struct {
	// Message is a human readable error message.
	Message string
	// Column is a column number of the error in the glob pattern. This value is 1-based, but zero
	// is valid value. Zero means the error occurred before reading first character. This happens
	// when a given pattern is empty. When the given pattern include a newline and line number
	// increases (invalid pattern), the column number falls back into always 0.
	Column int
}

InvalidGlobPatternError is an error on invalid glob pattern.

func ValidatePathGlob

func ValidatePathGlob(pat string) []InvalidGlobPatternError

ValidatePathGlob checks a given input as glob pattern for file paths. It returns list of errors found by the validation. See the following URL for more details of the syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

func ValidateRefGlob

func ValidateRefGlob(pat string) []InvalidGlobPatternError

ValidateRefGlob checks a given input as glob pattern for Git ref names. It returns list of errors found by the validation. See the following URL for more details of the syntax: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

func (*InvalidGlobPatternError) Error

func (err *InvalidGlobPatternError) Error() string

func (*InvalidGlobPatternError) String

func (err *InvalidGlobPatternError) String() string

type Job

type Job struct {
	// ID is an ID of the job, which is key of job configuration objects.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_id
	ID *String
	// Name is a name of job that user can specify freely.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idname
	Name *String
	// Needs is list of job IDs which should be run before running this job.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds
	Needs []*String
	// RunsOn is runner configuration which run the job.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
	RunsOn *Runner
	// Permissions is permission configuration for running the job.
	Permissions *Permissions
	// CacheMode overrides the workflow's cache access for this job. Nil means inherit.
	CacheMode *CacheMode
	// Environment is environment specification where the job runs.
	Environment *Environment
	// Concurrency is concurrency configuration on running the job.
	Concurrency *Concurrency
	// Outputs is map from output name to output specifications.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs
	Outputs map[string]*Output
	// Env is environment variables setup while running the job.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idenv
	Env *Env
	// Defaults is default configurations of how to run scripts.
	Defaults *Defaults
	// If is a condition whether this job should be run.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idif
	If *String
	// Steps is list of steps to be run in the job.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps
	Steps []*Step
	// TimeoutMinutes is timeout value of running the job in minutes.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idtimeout-minutes
	TimeoutMinutes *Float
	// CancelTimeoutMinutes is the time allowed for cancellation cleanup in minutes.
	CancelTimeoutMinutes *Float
	// Strategy is strategy configuration of running the job.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy
	Strategy *Strategy
	// ContinueOnError is a flag to show if execution should continue on error.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
	ContinueOnError *Bool
	// Container is container configuration to run the job.
	Container *Container
	// Services is a services configurations.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices
	Services *Services
	// WorkflowCall is a workflow call by 'uses:'.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
	WorkflowCall *WorkflowCall
	// Snapshot is a custom image snapshot.
	// https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idsnapshot
	Snapshot *Snapshot
	// Pos is a position in source.
	Pos *Pos
}

Job is configuration of how to run a job. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobs

type JobTimeoutPolicy added in v1.13.0

type JobTimeoutPolicy struct {
	// contains filtered or unexported fields
}

JobTimeoutPolicy is the value of the "require-job-timeout" policy in the configuration file. The value is a boolean which turns the check on and off, or a mapping which turns it on and sets the allowed range in its "min-minutes" and "max-minutes" keys.

func RequireJobTimeout added in v1.13.0

func RequireJobTimeout(maxMinutes float64) *JobTimeoutPolicy

RequireJobTimeout creates a JobTimeoutPolicy which turns the check on. The argument is the largest allowed number of minutes, where a value which is not larger than zero sets no upper limit.

func RequireJobTimeoutRange added in v1.16.0

func RequireJobTimeoutRange(minMinutes, maxMinutes float64) (*JobTimeoutPolicy, error)

RequireJobTimeoutRange requires job timeouts within the inclusive bounds. Zero omits a bound. It rejects negative or non-finite bounds and a minimum larger than a nonzero maximum.

func (*JobTimeoutPolicy) Enabled added in v1.13.0

func (p *JobTimeoutPolicy) Enabled() bool

Enabled returns whether the check is turned on. It returns false when the receiver is nil.

func (*JobTimeoutPolicy) MaxMinutes added in v1.13.0

func (p *JobTimeoutPolicy) MaxMinutes() (float64, bool)

MaxMinutes returns the largest allowed "timeout-minutes:" value in minutes. The second return value is false when the policy sets no upper limit.

func (*JobTimeoutPolicy) MinMinutes added in v1.16.0

func (p *JobTimeoutPolicy) MinMinutes() (float64, bool)

MinMinutes returns the smallest allowed timeout in minutes. The boolean is false without an enabled lower bound.

func (*JobTimeoutPolicy) UnmarshalYAML added in v1.13.0

func (p *JobTimeoutPolicy) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type Linter

type Linter struct {
	// contains filtered or unexported fields
}

Linter is struct to lint workflow files.

Example
package main

import (
	"fmt"
	"os"
	"path/filepath"

	"actionlint.kjanat.dev"
)

func main() {
	// Specify linter options
	o := &actionlint.LinterOptions{
		IgnorePatterns: []string{`'label ".+" is unknown'`},
		// Other options...
	}

	// Create Linter instance which outputs errors to stdout
	l, err := actionlint.NewLinter(os.Stdout, o)
	if err != nil {
		panic(err)
	}

	// File to check
	f := filepath.Join("testdata", "examples", "main.yaml")

	// First return value is an array of lint errors found in the workflow files. The second return
	// value is an error of actionlint itself. This call outputs the lint errors to stdout. Use
	// io.Discard to prevent the output.
	//
	// There are several methods to run linter.
	// - LintFile: Check the given single file
	// - LintFiles: Check the given multiple files
	// - LintDir: Check all workflow files in the given single directory recursively
	// - LintRepository: Check all workflow files under .github/workflows in the given repository
	// - LintStdin: Check the given workflow content read from STDIN
	// - Lint: Check the given workflow content assuming the given file path
	errs, err := l.LintFile(f, nil)
	if err != nil {
		panic(err)
	}

	fmt.Println(len(errs), "lint errors found by actionlint")
}
Example (YourOwnRule)
package main

import (
	"fmt"
	"io"
	"path/filepath"

	"actionlint.kjanat.dev"
)

// A rule type to check every steps have their names.
type RuleStepName struct {
	// Embedding RuleBase struct implements the minimal Rule interface.
	actionlint.RuleBase
}

// Reimplement methods in RuleBase. Visit* methods are called on checking workflows.
func (r *RuleStepName) VisitStep(n *actionlint.Step) error {
	// Implement your own check
	if n.Name == nil {
		// RuleBase provides methods to report errors. See RuleBase.Error and RuleBase.Errorf.
		r.Error(n.Pos, "every step must have its name")
	}
	return nil
}

func NewRuleStepName() *RuleStepName {
	return &RuleStepName{
		RuleBase: actionlint.NewRuleBase("step-name", "Checks every step has their own name"),
	}
}

func main() {
	// The function set at OnRulesCreated is called after rule instances are created. You can
	// add/remove some rules and return the modified slice. This function is called on linting
	// each workflow files.
	o := &actionlint.LinterOptions{
		OnRulesCreated: func(rules []actionlint.Rule) []actionlint.Rule {
			rules = append(rules, NewRuleStepName())
			return rules
		},
	}

	l, err := actionlint.NewLinter(io.Discard, o)
	if err != nil {
		panic(err)
	}

	f := filepath.Join("testdata", "ok", "minimal.yaml")

	// First return value is an array of lint errors found in the workflow file.
	errs, err := l.LintFile(f, nil)
	if err != nil {
		panic(err)
	}

	// `errs` includes errors like below:
	//
	// testdata/examples/main.yaml:14:9: every step must have its name [step-name]
	//    |
	// 14 |       - uses: actions/checkout@v4
	//    |         ^~~~~
	fmt.Println(len(errs), "lint errors found by actionlint")
}
Output:
1 lint errors found by actionlint

func NewLinter

func NewLinter(out io.Writer, opts *LinterOptions) (*Linter, error)

NewLinter creates a new Linter instance. The out parameter is used to output errors from Linter instance. Set io.Discard if you don't want the outputs. The opts parameter is LinterOptions instance which configures behavior of linting.

func (*Linter) GenerateDefaultConfig

func (l *Linter) GenerateDefaultConfig(dir string) error

GenerateDefaultConfig generates default config file at ".github/actionlint.yaml" in the project which the given directory path belongs to. When the directory path is empty, the current directory will be used instead.

func (*Linter) Lint

func (l *Linter) Lint(path string, content []byte, project *Project) ([]*Error, error)

Lint lints YAML workflow file content given as byte slice. The path parameter is used as file path where the content came from. When nil is passed to the project parameter, it tries to find the project from the path parameter.

func (*Linter) LintDir

func (l *Linter) LintDir(dir string, project *Project) ([]*Error, error)

LintDir lints all YAML workflow files in the given directory recursively.

func (*Linter) LintFile

func (l *Linter) LintFile(path string, project *Project) ([]*Error, error)

LintFile lints one YAML workflow file and outputs the errors to given writer. The project parameter can be nil. In the case, the project is detected from the given path.

func (*Linter) LintFiles

func (l *Linter) LintFiles(filepaths []string, project *Project) ([]*Error, error)

LintFiles lints YAML workflow files and outputs the errors to given writer. It applies lint rules to all given files. The project parameter can be nil. In the case, a project is detected from the file path.

func (*Linter) LintRepository

func (l *Linter) LintRepository(dir string) ([]*Error, error)

LintRepository lints YAML workflow files and outputs the errors to given writer. It finds the nearest `.github/workflows` directory based on `dir` and applies lint rules to all YAML workflow files under the directory. When the directory path is empty, the current working directory will be used instead.

func (*Linter) LintStdin

func (l *Linter) LintStdin(stdin io.Reader) ([]*Error, error)

LintStdin lints the content read from STDIN. The stdin parameter is a reader to read from STDIN, which is usually os.Stdin. The file name is determined by LinterOptions.StdinFileName. When the option is empty, "<stdin>" is the default value.

type LinterOptions

type LinterOptions struct {
	// Verbose is flag if verbose log output is enabled.
	Verbose bool
	// Debug is flag if debug log output is enabled.
	Debug bool
	// LogWriter is io.Writer object to use to print log outputs. Note that error outputs detected
	// by the linter are not included in the log outputs.
	LogWriter io.Writer
	// Color is option for colorizing error outputs. See ColorOptionKind document for each enum values.
	Color ColorOptionKind
	// Oneline is flag if one line output is enabled. When enabling it, one error is output per one
	// line. It is useful when reading outputs from programs.
	Oneline bool
	// Shellcheck is executable for running shellcheck external command. It can be command name like
	// "shellcheck" or file path like "/path/to/shellcheck", "path/to/shellcheck". When this value
	// is empty, shellcheck won't run to check scripts in workflow file.
	Shellcheck string
	// Pyflakes is executable for running pyflakes external command. It can be command name like "pyflakes"
	// or file path like "/path/to/pyflakes", "path/to/pyflakes". When this value is empty, pyflakes
	// won't run to check scripts in workflow file.
	Pyflakes string
	// IgnorePatterns is list of regular expression to filter errors. The pattern is applied to error
	// messages. When an error is matched, the error is ignored.
	IgnorePatterns []string
	// ConfigFile is a path to config file. Empty string means no config file path is given. In
	// the case, actionlint will try to read config from .github/actionlint.yaml.
	ConfigFile string
	// Format is a custom template to format error messages. It must follow Go Template format and
	// contain at least one {{ }} placeholder. https://pkg.go.dev/text/template
	Format string
	// StdinFileName is a file name when reading input from stdin. When this value is empty, "<stdin>"
	// is used as the default value.
	StdinFileName string
	// WorkingDir is a file path to the current working directory. When this value is empty, os.Getwd
	// will be used to get a working directory.
	WorkingDir string
	// OnRulesCreated is a hook to add or remove the check rules. This function is called on checking
	// every workflow files. Rules created by Linter instance are passed to the argument and the
	// function should return the modified rules.
	// Note that syntax errors may be reported even if this function returns nil or an empty slice.
	OnRulesCreated func([]Rule) []Rule
	// OnFilesSelected is called with the exact file set passed to LintFiles. The callback receives
	// a copy so modifying it does not affect linting.
	OnFilesSelected func([]string)
	// Context bounds the lifetime of the linting. Cancelling it kills the shellcheck and pyflakes
	// child processes which are running. When this value is nil, context.Background() is used.
	Context context.Context
}

LinterOptions is set of options for Linter instance. This struct is used for NewLinter factory function call. The zero value LinterOptions{} represents the default behavior.

type LocalActionsCache

type LocalActionsCache struct {
	// contains filtered or unexported fields
}

LocalActionsCache is cache for local actions' metadata. It avoids repeating to find/read/parse local action's metadata file (action.yml). This cache is not available across multiple repositories. One LocalActionsCache instance needs to be created per one repository.

func NewLocalActionsCache

func NewLocalActionsCache(proj *Project, dbg io.Writer) *LocalActionsCache

NewLocalActionsCache creates new LocalActionsCache instance for the given project.

func (*LocalActionsCache) FindMetadata

func (c *LocalActionsCache) FindMetadata(spec string) (*ActionMetadata, bool, error)

FindMetadata finds metadata for given spec. The spec should indicate for local action hence it should start with "./". The first return value can be nil even if error did not occur. LocalActionCache caches that the action was not found. At first search, it returns an error that the action was not found. But at the second search, it does not return an error even if the result is nil. This behavior prevents repeating to report the same error from multiple places. Calling this method is thread-safe.

type LocalActionsCacheFactory

type LocalActionsCacheFactory struct {
	// contains filtered or unexported fields
}

LocalActionsCacheFactory is a factory to create LocalActionsCache instances. LocalActionsCache should be created for each repositories. LocalActionsCacheFactory creates new LocalActionsCache instance per repository (project).

func NewLocalActionsCacheFactory

func NewLocalActionsCacheFactory(dbg io.Writer) *LocalActionsCacheFactory

NewLocalActionsCacheFactory creates a new LocalActionsCacheFactory instance.

func (*LocalActionsCacheFactory) GetCache

GetCache returns LocalActionsCache instance for the given project. One LocalActionsCache is created per one repository. Created instances are cached and will be used when caches are requested for the same projects. This method is not thread safe.

type LocalReusableWorkflowCache

type LocalReusableWorkflowCache struct {
	// contains filtered or unexported fields
}

LocalReusableWorkflowCache is a cache for local reusable workflow metadata files. It avoids find/read/parse local reusable workflow YAML files. This cache is dedicated for a single project (repository) indicated by 'proj' field. One LocalReusableWorkflowCache instance needs to be created per one project.

func NewLocalReusableWorkflowCache

func NewLocalReusableWorkflowCache(proj *Project, cwd string, dbg io.Writer) *LocalReusableWorkflowCache

NewLocalReusableWorkflowCache creates a new LocalReusableWorkflowCache instance for the given project. 'cwd' is a current working directory as an absolute file path. The 'Local' means that the cache instance is project-local. It is not available across multiple projects.

func (*LocalReusableWorkflowCache) FindMetadata

FindMetadata finds/parses a reusable workflow metadata located by the 'spec' argument. When project is not set to 'proj' field or the spec does not start with "./", this method immediately returns with nil.

Read and parse errors are cached alongside metadata and returned on every lookup. Each caller can report the failure at its own source position, regardless of the order of concurrent checks.

Calling this method is thread-safe.

func (*LocalReusableWorkflowCache) WriteWorkflowCallEvent

func (c *LocalReusableWorkflowCache) WriteWorkflowCallEvent(wpath string, event *WorkflowCallEvent)

WriteWorkflowCallEvent writes reusable workflow metadata by converting from WorkflowCallEvent AST node. The 'wpath' parameter is a path to the workflow file of the AST, which is a relative to the project root directory or an absolute path. This method does nothing when (1) no project is set, (2) it could not convert the workflow path to workflow call spec, (3) some cache for the workflow is already existing. This method is thread safe.

func (*LocalReusableWorkflowCache) WriteWorkflowCallEventFromWorkflow added in v1.13.0

func (c *LocalReusableWorkflowCache) WriteWorkflowCallEventFromWorkflow(wpath string, event *WorkflowCallEvent, w *Workflow)

WriteWorkflowCallEventFromWorkflow is like WriteWorkflowCallEvent but also records the permissions each job of the reusable workflow requires, taken from the workflow AST. The permission check on workflow calls needs them. Passing a nil 'w' is equivalent to WriteWorkflowCallEvent. The same do-nothing conditions and thread safety apply.

type LocalReusableWorkflowCacheFactory

type LocalReusableWorkflowCacheFactory struct {
	// contains filtered or unexported fields
}

LocalReusableWorkflowCacheFactory is a factory object to create a LocalReusableWorkflowCache instance per project.

func NewLocalReusableWorkflowCacheFactory

func NewLocalReusableWorkflowCacheFactory(cwd string, dbg io.Writer) *LocalReusableWorkflowCacheFactory

NewLocalReusableWorkflowCacheFactory creates a new LocalReusableWorkflowCacheFactory instance.

func (*LocalReusableWorkflowCacheFactory) GetCache

GetCache returns a new or existing LocalReusableWorkflowCache instance per project. When a instance was already created for the project, this method returns the existing instance. Otherwise it creates a new instance and returns it.

type LogLevel

type LogLevel int

LogLevel is log level of logger used in Linter instance.

type LogicalOpNode

type LogicalOpNode struct {
	// Kind is a kind to show which operator is used.
	Kind LogicalOpNodeKind
	// Left is an expression for left hand side of the binary operator.
	Left ExprNode
	// Right is an expression for right hand side of the binary operator.
	Right ExprNode
}

LogicalOpNode is node for logical binary operators; && or ||.

func (*LogicalOpNode) Token

func (n *LogicalOpNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type LogicalOpNodeKind

type LogicalOpNodeKind int

LogicalOpNodeKind is a kind of logical operators; && and ||.

const (
	// LogicalOpNodeKindInvalid is an invalid and initial value of LogicalOpNodeKind.
	LogicalOpNodeKindInvalid LogicalOpNodeKind = iota
	// LogicalOpNodeKindAnd is a kind for && operator.
	LogicalOpNodeKindAnd
	// LogicalOpNodeKindOr is a kind for || operator.
	LogicalOpNodeKindOr
)

func (LogicalOpNodeKind) String

func (k LogicalOpNodeKind) String() string

type Matrix

type Matrix struct {
	// Values stores mappings from name to values. Keys are in lower case since they are case-insensitive.
	Rows map[string]*MatrixRow
	// Include is list of combinations of matrix values and additional values on running matrix combinations.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
	Include *MatrixCombinations
	// Exclude is list of combinations of matrix values which should not be run. Combinations in
	// this list will be removed from combinations of matrix to run.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#example-excluding-configurations-from-a-matrix
	Exclude *MatrixCombinations
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Matrix is matrix variations configuration of a job. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

type MatrixAssign

type MatrixAssign struct {
	// Key is a name of the matrix value.
	Key *String
	// Value is the value selected from values in row.
	Value RawYAMLValue
}

MatrixAssign represents which value should be taken in the row of the matrix. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

type MatrixCombination

type MatrixCombination struct {
	Assigns map[string]*MatrixAssign
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
}

MatrixCombination is combination of matrix value assignments to define one of matrix variations. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

type MatrixCombinations

type MatrixCombinations struct {
	Combinations []*MatrixCombination
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
}

MatrixCombinations is list of combinations of matrix assignments used for 'include' and 'exclude' sections. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

func (*MatrixCombinations) ContainsExpression

func (cs *MatrixCombinations) ContainsExpression() bool

ContainsExpression returns if the combinations section includes at least one expression node.

type MatrixRow

type MatrixRow struct {
	// Name is a name of matrix value.
	Name *String
	// Values is variations of values which the matrix value can take.
	Values []RawYAMLValue
	// Expression is a string when expression syntax ${{ }} is used for this section.
	Expression *String
}

MatrixRow is one row of matrix. One matrix row can take multiple values. Those variations are stored as row of values in this struct. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix

type NotOpNode

type NotOpNode struct {
	// Operand is an expression at operand of ! operator.
	Operand ExprNode
	// contains filtered or unexported fields
}

NotOpNode is node for unary ! operator.

func (*NotOpNode) Token

func (n *NotOpNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type NullNode

type NullNode struct {
	// contains filtered or unexported fields
}

NullNode is node for null literal.

func (*NullNode) Token

func (n *NullNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type NullType

type NullType struct{}

NullType is type for null value.

func (NullType) Assignable

func (ty NullType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type.

func (NullType) DeepCopy

func (ty NullType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (NullType) Merge

func (ty NullType) Merge(other ExprType) ExprType

Merge merges other type into this type. When other type conflicts with this type, the merged result is any type as fallback.

func (NullType) String

func (ty NullType) String() string

type NumberType

type NumberType struct{}

NumberType is type for number values such as integer or float.

func (NumberType) Assignable

func (ty NumberType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type.

func (NumberType) DeepCopy

func (ty NumberType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (NumberType) Merge

func (ty NumberType) Merge(other ExprType) ExprType

Merge merges other type into this type. When other type conflicts with this type, the merged result is any type as fallback.

func (NumberType) String

func (ty NumberType) String() string

type ObjectDerefNode

type ObjectDerefNode struct {
	// Receiver is an expression at receiver of property dereference.
	Receiver ExprNode
	// Property is a name of property to access.
	Property string
}

ObjectDerefNode represents property dereference of object like 'foo.bar'.

func (ObjectDerefNode) Token

func (n ObjectDerefNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type ObjectType

type ObjectType struct {
	// Props is map from properties name to their type.
	Props map[string]ExprType
	// Mapped is an element type of this object. This means all props have the type. For example,
	// The element type of env context is string.
	// AnyType means its property types can be any type so it shapes a loose object. Setting nil
	// means properties are mapped to no type so it shapes a strict object.
	//
	// Invariant: All types in Props field must be assignable to this type.
	Mapped ExprType
}

ObjectType is type for objects, which can hold key-values.

func NewEmptyObjectType

func NewEmptyObjectType() *ObjectType

NewEmptyObjectType creates new loose ObjectType instance which allows unknown props. When accessing to unknown props, their values will fall back to any.

func NewEmptyStrictObjectType

func NewEmptyStrictObjectType() *ObjectType

NewEmptyStrictObjectType creates new ObjectType instance which does not allow unknown props.

func NewMapObjectType

func NewMapObjectType(t ExprType) *ObjectType

NewMapObjectType creates new ObjectType which maps keys to a specific type value.

func NewObjectType

func NewObjectType(props map[string]ExprType) *ObjectType

NewObjectType creates new loose ObjectType instance which allows unknown props with given props.

func NewStrictObjectType

func NewStrictObjectType(props map[string]ExprType) *ObjectType

NewStrictObjectType creates new ObjectType instance which does not allow unknown props with given prop types.

func (*ObjectType) Assignable

func (ty *ObjectType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type. In other words, rhs type is more strict than lhs (receiver) type.

func (*ObjectType) DeepCopy

func (ty *ObjectType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (*ObjectType) IsLoose

func (ty *ObjectType) IsLoose() bool

IsLoose returns if the type is a loose object, which allows any unknown props.

func (*ObjectType) IsStrict

func (ty *ObjectType) IsStrict() bool

IsStrict returns if the type is a strict object, which means no unknown prop is allowed.

func (*ObjectType) Loose

func (ty *ObjectType) Loose()

Loose sets the object is loose, which means any properties can be set.

func (*ObjectType) Merge

func (ty *ObjectType) Merge(other ExprType) ExprType

Merge merges two object types into one. When other object has unknown props, they are merged into current object. When both have same property, when they are assignable, it remains as-is. Otherwise, the property falls back to any type.

func (*ObjectType) Strict

func (ty *ObjectType) Strict()

Strict sets the object is strict, which means only known properties are allowed.

func (*ObjectType) String

func (ty *ObjectType) String() string

type Output

type Output struct {
	// Name is name of output.
	Name *String
	// Value is value of output.
	Value *String
}

Output is output entry of the job. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idoutputs

type Pass

type Pass interface {
	// VisitStep is callback when visiting Step node. It returns internal error when it cannot continue the process
	VisitStep(node *Step) error
	// VisitJobPre is callback when visiting Job node before visiting its children. It returns internal error when it cannot continue the process
	VisitJobPre(node *Job) error
	// VisitJobPost is callback when visiting Job node after visiting its children. It returns internal error when it cannot continue the process
	VisitJobPost(node *Job) error
	// VisitWorkflowPre is callback when visiting Workflow node before visiting its children. It returns internal error when it cannot continue the process
	VisitWorkflowPre(node *Workflow) error
	// VisitWorkflowPost is callback when visiting Workflow node after visiting its children. It returns internal error when it cannot continue the process
	VisitWorkflowPost(node *Workflow) error
}

Pass is an interface to traverse a workflow syntax tree

type PathConfig

type PathConfig struct {
	// Ignore suppresses diagnostics whose message matches any of these Go regular expressions.
	//
	// Applies only to workflow files matching the parent path glob. For example,
	// `["shellcheck reported issue in this script: SC2086"]` ignores that ShellCheck diagnostic.
	// Omit this key, use `null`, or use `[]` to suppress nothing. Like the `-ignore` CLI option.
	Ignore IgnorePatterns `yaml:"ignore" jsonschema:"nullable"`
}

PathConfig is a configuration for specific file path pattern. This is for values of the "paths" mapping in the configuration file.

type PermissionLevel added in v1.13.0

type PermissionLevel int

PermissionLevel is an access level of a single permission scope of the GITHUB_TOKEN.

const (
	// PermissionLevelNone means the scope grants no access.
	PermissionLevelNone PermissionLevel = iota
	// PermissionLevelRead means the scope grants read access.
	PermissionLevelRead
	// PermissionLevelWrite means the scope grants write access, which includes read access.
	PermissionLevelWrite
)

func (PermissionLevel) String added in v1.13.0

func (l PermissionLevel) String() string

String returns the level as it is written in a "permissions:" mapping.

type PermissionScope

type PermissionScope struct {
	// Name is name of the scope.
	Name *String
	// Value is permission value of the scope.
	Value *String
}

PermissionScope is struct for respective permission scope like "issues", "checks", ... https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token

type PermissionScopeLevels added in v1.13.0

type PermissionScopeLevels map[string]PermissionLevel

PermissionScopeLevels maps a permission scope name to its access level. A scope absent from the map is PermissionLevelNone.

type Permissions

type Permissions struct {
	// All represents a permission value for all the scopes at once.
	All *String
	// Scopes is mappings from scope name to its permission configuration
	Scopes map[string]*PermissionScope
	// Pos is a position in source.
	Pos *Pos
}

Permissions is set of permission configurations in workflow file. All permissions can be set at once. Or each permission can be configured respectively. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions

type PermissionsPolicy added in v1.16.0

type PermissionsPolicy struct {
	// contains filtered or unexported fields
}

PermissionsPolicy selects where the "require-permissions" policy requires a declaration.

func RequirePermissions added in v1.16.0

func RequirePermissions(scope string) (*PermissionsPolicy, error)

RequirePermissions enables the policy with "workflow" or "job" scope. Other values return an error.

func (*PermissionsPolicy) Enabled added in v1.16.0

func (p *PermissionsPolicy) Enabled() bool

Enabled reports whether the policy is enabled. A nil receiver disables it.

func (*PermissionsPolicy) Scope added in v1.16.0

func (p *PermissionsPolicy) Scope() string

Scope returns "workflow" or "job", or an empty string when the policy is disabled.

func (*PermissionsPolicy) UnmarshalYAML added in v1.16.0

func (p *PermissionsPolicy) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type Policy added in v1.13.0

type Policy struct {
	// CacheCallUnrestricted requires explicit cache ceilings on low-trust reusable calls.
	// Enabled by default. Set false to disable it; null or omission keeps the default.
	CacheCallUnrestricted *bool `yaml:"cache-call-unrestricted" jsonschema:"nullable,default=true"`
	// CacheOperation reports official cache action steps disabled by an explicit cache mode.
	// Enabled by default. Set false to disable it; null or omission keeps the default.
	CacheOperation *bool `yaml:"cache-operation" jsonschema:"nullable,default=true"`
	// CacheWriteUntrusted reports write-capable cache modes on low-trust triggers.
	// Enabled by default. Set false to disable it; null or omission keeps the default.
	CacheWriteUntrusted *bool `yaml:"cache-write-untrusted" jsonschema:"nullable,default=true"`
	// DisallowSuppressions restricts inline cache policy exceptions. `true` or `{}` reports
	// each prohibited directive and retains its original violations. Omission, null, or false
	// permits exceptions. Both ignore and ignore-next-line are covered equally.
	//
	// Use `{rules: [cache-call-unrestricted], report: all}` to restrict selected rule IDs.
	// Omitted rules selects all suppressible rules; an explicit list must be nonempty.
	// Report accepts suppression (directive only), violation (original findings only), or all (both kinds of diagnostic).
	DisallowSuppressions *SuppressionsPolicy `yaml:"disallow-suppressions" jsonschema:"nullable"`
	// RequireCommitHash requires `uses:` references to be pinned to a full commit SHA, or an image digest
	// for Docker images, when set to `true`.
	//
	// Set `false` to disable the check. Omit this key or use `null` to leave it unset; the check is
	// disabled by default. Local references and references built with expressions are skipped.
	RequireCommitHash *bool `yaml:"require-commit-hash" jsonschema:"nullable"`
	// RequireJobTimeout requires jobs to declare `timeout-minutes` when set to `true`.
	//
	// Use `{min-minutes: 5, max-minutes: 60}` to require a timeout between 5 and 60 minutes.
	// Either bound may be omitted. Bounds must be finite and greater than zero, and the minimum
	// must not exceed the maximum. `{}` requires the key without bounds. Reusable workflow calls are skipped.
	//
	// Set `false` to disable the check. Omit this key or use `null` to leave it unset; the check is
	// disabled by default.
	RequireJobTimeout *JobTimeoutPolicy `yaml:"require-job-timeout" jsonschema:"nullable"`
	// RequirePermissions requires an explicit `permissions:` declaration.
	//
	// `true` or `{scope: workflow}` requires a workflow-level declaration, including `permissions: {}`.
	// `{scope: job}` requires a declaration on every job, including reusable workflow calls.
	// `{}` enables workflow scope. This checks presence only; it does not infer the scopes a job needs.
	//
	// Set `false` to disable the check. Omit this key or use `null` to leave it unset; it is disabled by default.
	RequirePermissions *PermissionsPolicy `yaml:"require-permissions" jsonschema:"nullable"`
	// RequiredActions lists actions that every workflow must use in its steps.
	//
	// Write entries like `uses:` values: `actions/checkout` accepts any ref, while
	// `actions/checkout@v4*` also matches the ref. Both halves support glob patterns; `*` does not
	// match `/`. Names are matched case-insensitively and refs case-sensitively.
	//
	// Use `[]` to disable the check. Omit this key or use `null` to leave it unset; no actions
	// are required by default. Actions inside composite actions or called workflows are not counted.
	RequiredActions []string `yaml:"required-actions" jsonschema:"nullable,minLength=1"`
}

Policy configures checks for cache safety and repository conventions. Cache policies are enabled by default; the remaining checks are opt-in. An omitted or null setting retains the check's default.

func (*Policy) UnmarshalYAML added in v1.13.0

func (p *Policy) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type Pos

type Pos struct {
	// Line is a line number of the position. This value is 1-based.
	Line int
	// Col is a column number of the position. This value is 1-based.
	Col int
}

Pos represents position in the file.

func (*Pos) IsBefore

func (p *Pos) IsBefore(other *Pos) bool

IsBefore returns if the position is before the other position. If they are equal, this function returns false.

func (*Pos) String

func (p *Pos) String() string

type Project

type Project struct {
	// contains filtered or unexported fields
}

Project represents one GitHub project. One Git repository corresponds to one project.

func NewProject

func NewProject(root string) (*Project, error)

NewProject creates a new instance with a file path to the root directory of the repository. This function returns an error when failing to parse an actionlint config file in the repository.

func (*Project) Config

func (p *Project) Config() *Config

Config returns config object of the GitHub project repository. The config file was read from ".github/actionlint.yaml" or ".github/actionlint.yml" when this Project instance was created. When no config was found, this method returns nil.

func (*Project) Knows

func (p *Project) Knows(path string) bool

Knows returns true when the project knows the given file. When a file is included in the project's directory, the project knows the file.

func (*Project) RootDir

func (p *Project) RootDir() string

RootDir returns a root directory path of the GitHub project repository.

func (*Project) WorkflowsDir

func (p *Project) WorkflowsDir() string

WorkflowsDir returns a ".github/workflows" directory path of the GitHub project repository. This method does not check if the directory exists.

type Projects

type Projects struct {
	// contains filtered or unexported fields
}

Projects represents set of projects. It caches Project instances which was created previously and reuses them.

func NewProjects

func NewProjects() *Projects

NewProjects creates new Projects instance.

func (*Projects) At

func (ps *Projects) At(path string) (*Project, error)

At returns the Project instance which the path belongs to. It returns nil if no project is found from the path.

type RawYAMLArray

type RawYAMLArray struct {
	// Elems is list of elements of the array value.
	Elems []RawYAMLValue
	// contains filtered or unexported fields
}

RawYAMLArray is raw YAML sequence value.

func (*RawYAMLArray) Equals

func (a *RawYAMLArray) Equals(other RawYAMLValue) bool

Equals returns if the other value is equal to the value.

func (*RawYAMLArray) Kind

func (a *RawYAMLArray) Kind() RawYAMLValueKind

Kind returns kind of raw YAML value.

func (*RawYAMLArray) Pos

func (a *RawYAMLArray) Pos() *Pos

Pos returns the start position of the value in the source file

func (*RawYAMLArray) String

func (a *RawYAMLArray) String() string

type RawYAMLObject

type RawYAMLObject struct {
	// Props is map from property names to their values. Keys are in lower case since they are case-insensitive.
	Props map[string]RawYAMLValue
	// contains filtered or unexported fields
}

RawYAMLObject is raw YAML mapping value.

func (*RawYAMLObject) Equals

func (o *RawYAMLObject) Equals(other RawYAMLValue) bool

Equals returns if the other value is equal to the value.

func (*RawYAMLObject) Kind

func (o *RawYAMLObject) Kind() RawYAMLValueKind

Kind returns kind of raw YAML value.

func (*RawYAMLObject) Pos

func (o *RawYAMLObject) Pos() *Pos

Pos returns the start position of the value in the source file

func (*RawYAMLObject) String

func (o *RawYAMLObject) String() string

type RawYAMLString

type RawYAMLString struct {
	// Value is string representation of the scalar node.
	Value string
	// Tag is the YAML tag of the scalar node, such as "!!str" or "!!int". A tag the parser rejects
	// is recorded as "!!str".
	Tag string
	// contains filtered or unexported fields
}

RawYAMLString is raw YAML scalar value.

func (*RawYAMLString) Equals

func (s *RawYAMLString) Equals(other RawYAMLValue) bool

Equals returns if the other value is equal to the value.

func (*RawYAMLString) Kind

func (s *RawYAMLString) Kind() RawYAMLValueKind

Kind returns kind of raw YAML value.

func (*RawYAMLString) Pos

func (s *RawYAMLString) Pos() *Pos

Pos returns the start position of the value in the source file

func (*RawYAMLString) String

func (s *RawYAMLString) String() string

type RawYAMLValue

type RawYAMLValue interface {
	// Kind returns kind of raw YAML value.
	Kind() RawYAMLValueKind
	// Equals returns if the other value is equal to the value.
	Equals(other RawYAMLValue) bool
	// Pos returns the start position of the value in the source file
	Pos() *Pos
	// String returns string representation of the value
	String() string
}

RawYAMLValue is a value at matrix variation. Any value can be put at matrix variations including mappings and arrays.

type RawYAMLValueKind

type RawYAMLValueKind int

RawYAMLValueKind is kind of raw YAML values

type RepositoryDispatchEvent

type RepositoryDispatchEvent struct {
	// Types is list of types which can trigger workflow.
	Types []*String
	// Pos is a position in source.
	Pos *Pos
}

RepositoryDispatchEvent is repository_dispatch event configuration. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#repository_dispatch

func (*RepositoryDispatchEvent) EventName

func (e *RepositoryDispatchEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type ReusableWorkflowCacheAccess added in v1.17.0

type ReusableWorkflowCacheAccess struct {
	// Mode is nil when the job inherits the calling workflow's access limit.
	Mode *CacheMode
	// Uses is the normalized local workflow reference, or empty for other jobs.
	Uses string
	// SourceUses preserves the local reference's source spelling for diagnostics.
	SourceUses string
	// Operations lists official cache action names used by this job's steps.
	Operations []string
}

ReusableWorkflowCacheAccess describes a job's declared cache access and any local callee.

type ReusableWorkflowMetadata

type ReusableWorkflowMetadata struct {
	Inputs  ReusableWorkflowMetadataInputs  `yaml:"inputs"`
	Outputs ReusableWorkflowMetadataOutputs `yaml:"outputs"`
	Secrets ReusableWorkflowMetadataSecrets `yaml:"secrets"`
	// JobPermissions maps a job ID of the reusable workflow to the permission scopes that job requires.
	// A job which declares no "permissions:" of its own and inherits none from the workflow has no entry,
	// and neither has a job whose declaration requires nothing.
	JobPermissions map[string]PermissionScopeLevels `yaml:"-"`
	// JobCacheAccess records effective declarations and local workflow calls by job ID.
	JobCacheAccess map[string]ReusableWorkflowCacheAccess `yaml:"-"`
}

ReusableWorkflowMetadata is metadata to validate local reusable workflows. This struct does not contain all metadata from YAML file. It only contains metadata which is necessary to validate reusable workflow files by actionlint.

type ReusableWorkflowMetadataInput

type ReusableWorkflowMetadataInput struct {
	// Name is a name of the input defined in the reusable workflow.
	Name string
	// Required is true when 'required' field of the input is set to true and no default value is set.
	Required bool
	// Type is a type of the input. When the input type is unknown, 'any' type is set.
	Type ExprType
}

ReusableWorkflowMetadataInput is an input metadata for validating local reusable workflow file.

func (*ReusableWorkflowMetadataInput) UnmarshalYAML

func (input *ReusableWorkflowMetadataInput) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ReusableWorkflowMetadataInputs

type ReusableWorkflowMetadataInputs map[string]*ReusableWorkflowMetadataInput

ReusableWorkflowMetadataInputs is a map from input name to reusable wokflow input metadata. The keys are in lower case since input names of workflow calls are case insensitive.

func (*ReusableWorkflowMetadataInputs) UnmarshalYAML

func (inputs *ReusableWorkflowMetadataInputs) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ReusableWorkflowMetadataOutput

type ReusableWorkflowMetadataOutput struct {
	// Name is a name of the output in the reusable workflow.
	Name string
}

ReusableWorkflowMetadataOutput is an output metadata for validating local reusable workflow file.

type ReusableWorkflowMetadataOutputs

type ReusableWorkflowMetadataOutputs map[string]*ReusableWorkflowMetadataOutput

ReusableWorkflowMetadataOutputs is a map from output name to reusable wokflow output metadata. The keys are in lower case since output names of workflow calls are case insensitive.

func (*ReusableWorkflowMetadataOutputs) UnmarshalYAML

func (outputs *ReusableWorkflowMetadataOutputs) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type ReusableWorkflowMetadataSecret

type ReusableWorkflowMetadataSecret struct {
	// Name is a name of the secret in the reusable workflow.
	Name string
	// Required indicates whether the secret is required by its reusable workflow. When this value
	// is true, workflow calls must set this secret unless secrets are not inherited.
	Required bool `yaml:"required"`
}

ReusableWorkflowMetadataSecret is a secret metadata for validating local reusable workflow file.

type ReusableWorkflowMetadataSecrets

type ReusableWorkflowMetadataSecrets map[string]*ReusableWorkflowMetadataSecret

ReusableWorkflowMetadataSecrets is a map from secret name to reusable wokflow secret metadata. The keys are in lower case since secret names of workflow calls are case insensitive.

func (*ReusableWorkflowMetadataSecrets) UnmarshalYAML

func (secrets *ReusableWorkflowMetadataSecrets) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

type Rule

type Rule interface {
	Pass
	Errs() []*Error
	Name() string
	Description() string
	EnableDebug(out io.Writer)
	SetConfig(cfg *Config)
	Config() *Config
}

Rule is an interface which all rule structs must meet.

type RuleAction

type RuleAction struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleAction is a rule to check running action in steps of jobs. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepsuses Agents: https://docs.github.com/api/article/body?pathname=/en/actions/reference/workflows-and-actions/workflow-syntax

func NewRuleAction

func NewRuleAction(cache *LocalActionsCache) *RuleAction

NewRuleAction creates new RuleAction instance.

func (*RuleAction) VisitStep

func (rule *RuleAction) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RuleBase

type RuleBase struct {
	// contains filtered or unexported fields
}

RuleBase is a struct to be a base of rule structs. Embed this struct to define default methods automatically

func NewRuleBase

func NewRuleBase(name string, desc string) RuleBase

NewRuleBase creates a new RuleBase instance. It should be embedded to your own rule instance.

func (*RuleBase) Config

func (r *RuleBase) Config() *Config

Config returns the user configuration of actionlint. When no config was set to this rule by SetConfig, this method returns nil.

func (*RuleBase) Debug

func (r *RuleBase) Debug(format string, args ...any)

Debug prints debug log to the output. The output is specified by the argument of EnableDebug method. By default, no output is set so debug log is not printed.

func (*RuleBase) Description

func (r *RuleBase) Description() string

Description returns the description of the rule.

func (*RuleBase) EnableDebug

func (r *RuleBase) EnableDebug(out io.Writer)

EnableDebug enables debug output from the rule. Given io.Writer instance is used to print debug information to console. Setting nil means disabling debug output.

func (*RuleBase) Error

func (r *RuleBase) Error(pos *Pos, msg string)

Error creates a new error from the source position and the error message and stores it in the rule instance. The errors can be accessed by Errs method.

func (*RuleBase) Errorf

func (r *RuleBase) Errorf(pos *Pos, format string, args ...any)

Errorf reports a new error with the source position and the formatted error message and stores it in the rule instance. The errors can be accessed by Errs method.

func (*RuleBase) Errs

func (r *RuleBase) Errs() []*Error

Errs returns errors found by the rule.

func (*RuleBase) Name

func (r *RuleBase) Name() string

Name returns the name of the rule.

func (*RuleBase) SetConfig

func (r *RuleBase) SetConfig(cfg *Config)

SetConfig populates user configuration of actionlint to the rule. When no config is set, rules should behave as if the default configuration is set.

func (*RuleBase) VisitJobPost

func (r *RuleBase) VisitJobPost(node *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RuleBase) VisitJobPre

func (r *RuleBase) VisitJobPre(node *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleBase) VisitStep

func (r *RuleBase) VisitStep(node *Step) error

VisitStep is callback when visiting Step node.

func (*RuleBase) VisitWorkflowPost

func (r *RuleBase) VisitWorkflowPost(node *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children.

func (*RuleBase) VisitWorkflowPre

func (r *RuleBase) VisitWorkflowPre(node *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleCacheCallUnrestricted added in v1.17.0

type RuleCacheCallUnrestricted struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleCacheCallUnrestricted checks explicit cache limits on low-trust reusable calls.

func NewRuleCacheCallUnrestricted added in v1.17.0

func NewRuleCacheCallUnrestricted() *RuleCacheCallUnrestricted

NewRuleCacheCallUnrestricted creates a cache-call-unrestricted rule.

func (*RuleCacheCallUnrestricted) VisitJobPre added in v1.17.0

func (r *RuleCacheCallUnrestricted) VisitJobPre(job *Job) error

VisitJobPre requires an explicit ceiling at each affected call site.

func (*RuleCacheCallUnrestricted) VisitWorkflowPre added in v1.17.0

func (r *RuleCacheCallUnrestricted) VisitWorkflowPre(w *Workflow) error

VisitWorkflowPre records trigger and workflow defaults.

type RuleCacheOperation added in v1.17.0

type RuleCacheOperation struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleCacheOperation checks cache actions which an explicit mode makes ineffective.

func NewRuleCacheOperation added in v1.17.0

func NewRuleCacheOperation() *RuleCacheOperation

NewRuleCacheOperation creates a cache-operation rule.

func (*RuleCacheOperation) VisitJobPre added in v1.17.0

func (r *RuleCacheOperation) VisitJobPre(job *Job) error

VisitJobPre resolves job overrides.

func (*RuleCacheOperation) VisitStep added in v1.17.0

func (r *RuleCacheOperation) VisitStep(step *Step) error

VisitStep checks the three official cache action entry points.

func (*RuleCacheOperation) VisitWorkflowPre added in v1.17.0

func (r *RuleCacheOperation) VisitWorkflowPre(w *Workflow) error

VisitWorkflowPre records the workflow's explicit mode.

type RuleCacheWriteUntrusted added in v1.17.0

type RuleCacheWriteUntrusted struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleCacheWriteUntrusted checks write grants on triggers with restricted cache defaults.

func NewRuleCacheWriteUntrusted added in v1.17.0

func NewRuleCacheWriteUntrusted() *RuleCacheWriteUntrusted

NewRuleCacheWriteUntrusted creates a cache-write-untrusted rule.

func (*RuleCacheWriteUntrusted) VisitJobPre added in v1.17.0

func (r *RuleCacheWriteUntrusted) VisitJobPre(job *Job) error

VisitJobPre checks the job's effective declaration, including reusable calls.

func (*RuleCacheWriteUntrusted) VisitWorkflowPre added in v1.17.0

func (r *RuleCacheWriteUntrusted) VisitWorkflowPre(w *Workflow) error

VisitWorkflowPre records trigger and workflow defaults.

type RuleCredentials

type RuleCredentials struct {
	RuleBase
}

RuleCredentials is a rule to check credentials in workflows

func NewRuleCredentials

func NewRuleCredentials() *RuleCredentials

NewRuleCredentials creates new RuleCredentials instance

func (*RuleCredentials) VisitJobPre

func (rule *RuleCredentials) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

type RuleDeprecatedCommands

type RuleDeprecatedCommands struct {
	RuleBase
}

RuleDeprecatedCommands is a rule checker to detect deprecated workflow commands. Currently 'set-state', 'set-output', `set-env' and 'add-path' are detected as deprecated.

- https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ - https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

func NewRuleDeprecatedCommands

func NewRuleDeprecatedCommands() *RuleDeprecatedCommands

NewRuleDeprecatedCommands creates a new RuleDeprecatedCommands instance.

func (*RuleDeprecatedCommands) VisitStep

func (rule *RuleDeprecatedCommands) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RuleEnvVar

type RuleEnvVar struct {
	RuleBase
}

RuleEnvVar is a rule checker to check environment variables setup.

func NewRuleEnvVar

func NewRuleEnvVar() *RuleEnvVar

NewRuleEnvVar creates new RuleEnvVar instance.

func (*RuleEnvVar) VisitJobPre

func (rule *RuleEnvVar) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleEnvVar) VisitStep

func (rule *RuleEnvVar) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RuleEnvVar) VisitWorkflowPre

func (rule *RuleEnvVar) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleEvents

type RuleEvents struct {
	RuleBase
}

RuleEvents is a rule to check 'on' field in workflow. https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows

func NewRuleEvents

func NewRuleEvents() *RuleEvents

NewRuleEvents creates new RuleEvents instance.

func (*RuleEvents) VisitWorkflowPre

func (rule *RuleEvents) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleExpression

type RuleExpression struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleExpression is a rule checker to check expression syntax in string values of workflow syntax. It checks syntax and semantics of the expressions including type checks and functions/contexts definitions. For more details see - https://docs.github.com/en/actions/learn-github-actions/contexts - https://docs.github.com/en/actions/learn-github-actions/expressions

func NewRuleExpression

func NewRuleExpression(actionsCache *LocalActionsCache, workflowCache *LocalReusableWorkflowCache) *RuleExpression

NewRuleExpression creates new RuleExpression instance.

func (*RuleExpression) VisitJobPost

func (rule *RuleExpression) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children

func (*RuleExpression) VisitJobPre

func (rule *RuleExpression) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleExpression) VisitStep

func (rule *RuleExpression) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RuleExpression) VisitWorkflowPost

func (rule *RuleExpression) VisitWorkflowPost(n *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children

func (*RuleExpression) VisitWorkflowPre

func (rule *RuleExpression) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleGlob

type RuleGlob struct {
	RuleBase
}

RuleGlob is a rule to check glob syntax. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet

func NewRuleGlob

func NewRuleGlob() *RuleGlob

NewRuleGlob creates new RuleGlob instance.

func (*RuleGlob) VisitJobPre

func (rule *RuleGlob) VisitJobPre(n *Job) error

func (*RuleGlob) VisitWorkflowPre

func (rule *RuleGlob) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleID

type RuleID struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleID is a rule to check step IDs in workflow.

func NewRuleID

func NewRuleID() *RuleID

NewRuleID creates a new RuleID instance.

func (*RuleID) VisitJobPost

func (rule *RuleID) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RuleID) VisitJobPre

func (rule *RuleID) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleID) VisitStep

func (rule *RuleID) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RuleIfCond

type RuleIfCond struct {
	RuleBase
}

RuleIfCond is a rule to check if: conditions.

func NewRuleIfCond

func NewRuleIfCond() *RuleIfCond

NewRuleIfCond creates new RuleIfCond instance.

func (*RuleIfCond) VisitJobPre

func (rule *RuleIfCond) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleIfCond) VisitStep

func (rule *RuleIfCond) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RuleJobNeeds

type RuleJobNeeds struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleJobNeeds is a rule to check 'needs' field in each job configuration. For more details, see https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idneeds

func NewRuleJobNeeds

func NewRuleJobNeeds() *RuleJobNeeds

NewRuleJobNeeds creates new RuleJobNeeds instance.

func (*RuleJobNeeds) VisitJobPre

func (rule *RuleJobNeeds) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleJobNeeds) VisitWorkflowPost

func (rule *RuleJobNeeds) VisitWorkflowPost(n *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children.

type RuleMatrix

type RuleMatrix struct {
	RuleBase
}

RuleMatrix is a rule checker to check 'matrix' field of job.

func NewRuleMatrix

func NewRuleMatrix() *RuleMatrix

NewRuleMatrix creates new RuleMatrix instance.

func (*RuleMatrix) VisitJobPre

func (rule *RuleMatrix) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

type RuleParallelSteps

type RuleParallelSteps struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleParallelSteps is a rule to check parallel steps: a 'wait' or 'cancel' step must refer to the ID of a preceding background step, and a 'parallel' group may only contain 'run' and 'uses' steps ('background', 'wait', 'wait-all', 'cancel', and nested 'parallel' steps are not allowed in it). https://github.blog/changelog/2026-06-25-actions-steps-can-now-be-run-in-parallel/

func NewRuleParallelSteps

func NewRuleParallelSteps() *RuleParallelSteps

NewRuleParallelSteps creates a new RuleParallelSteps instance.

func (*RuleParallelSteps) VisitJobPost

func (rule *RuleParallelSteps) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RuleParallelSteps) VisitJobPre

func (rule *RuleParallelSteps) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleParallelSteps) VisitStep

func (rule *RuleParallelSteps) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RulePermissions

type RulePermissions struct {
	RuleBase
}

RulePermissions is a rule checker to check permission configurations in a workflow. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#defining-access-for-the-github_token-scopes

func NewRulePermissions

func NewRulePermissions() *RulePermissions

NewRulePermissions creates new RulePermissions instance.

func (*RulePermissions) VisitJobPre

func (rule *RulePermissions) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RulePermissions) VisitWorkflowPre

func (rule *RulePermissions) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RulePyflakes

type RulePyflakes struct {
	RuleBase
	// contains filtered or unexported fields
}

RulePyflakes is a rule to check Python scripts at 'run:' using pyflakes. https://github.com/PyCQA/pyflakes

func NewRulePyflakes

func NewRulePyflakes(executable string, proc *concurrentProcess) (*RulePyflakes, error)

NewRulePyflakes creates new RulePyflakes instance. Parameter executable can be command name or relative/absolute file path. When the given executable is not found in system, it returns an error.

func (*RulePyflakes) VisitJobPost

func (rule *RulePyflakes) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RulePyflakes) VisitJobPre

func (rule *RulePyflakes) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RulePyflakes) VisitStep

func (rule *RulePyflakes) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RulePyflakes) VisitWorkflowPost

func (rule *RulePyflakes) VisitWorkflowPost(n *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children.

func (*RulePyflakes) VisitWorkflowPre

func (rule *RulePyflakes) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleRequireCommitHash added in v1.13.0

type RuleRequireCommitHash struct {
	RuleBase
}

RuleRequireCommitHash is a rule to check that every "uses:" is pinned to something immutable, which is a full-length commit SHA for an action or a reusable workflow and an image digest for a Docker image. The "require-commit-hash" policy in the configuration file enables it.

func NewRuleRequireCommitHash added in v1.13.0

func NewRuleRequireCommitHash() *RuleRequireCommitHash

NewRuleRequireCommitHash creates a new RuleRequireCommitHash instance.

func (*RuleRequireCommitHash) VisitJobPre added in v1.13.0

func (rule *RuleRequireCommitHash) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleRequireCommitHash) VisitStep added in v1.13.0

func (rule *RuleRequireCommitHash) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

type RuleRequireJobTimeout added in v1.13.0

type RuleRequireJobTimeout struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleRequireJobTimeout is a rule to check that every job sets "timeout-minutes:". The "require-job-timeout" policy enables it and can set inclusive minimum and maximum bounds. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idtimeout-minutes

func NewRuleRequireJobTimeout added in v1.13.0

func NewRuleRequireJobTimeout(policy *JobTimeoutPolicy) *RuleRequireJobTimeout

NewRuleRequireJobTimeout creates a new RuleRequireJobTimeout instance with the given policy.

func (*RuleRequireJobTimeout) VisitJobPre added in v1.13.0

func (rule *RuleRequireJobTimeout) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

type RuleRequirePermissions added in v1.16.0

type RuleRequirePermissions struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleRequirePermissions checks for explicit permissions at the configured scope.

func NewRuleRequirePermissions added in v1.16.0

func NewRuleRequirePermissions(policy *PermissionsPolicy) *RuleRequirePermissions

NewRuleRequirePermissions creates a rule for the given policy.

func (*RuleRequirePermissions) VisitJobPre added in v1.16.0

func (rule *RuleRequirePermissions) VisitJobPre(n *Job) error

VisitJobPre checks each job declaration when job scope is enabled.

func (*RuleRequirePermissions) VisitWorkflowPre added in v1.16.0

func (rule *RuleRequirePermissions) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre checks the workflow declaration when workflow scope is enabled.

type RuleRequiredActions added in v1.13.0

type RuleRequiredActions struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleRequiredActions is a rule to check that a workflow uses the actions which the repository requires. The "required-actions" policy in the configuration file enables it and lists the actions.

func NewRuleRequiredActions added in v1.13.0

func NewRuleRequiredActions() *RuleRequiredActions

NewRuleRequiredActions creates a new RuleRequiredActions instance.

func (*RuleRequiredActions) VisitStep added in v1.13.0

func (rule *RuleRequiredActions) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RuleRequiredActions) VisitWorkflowPost added in v1.13.0

func (rule *RuleRequiredActions) VisitWorkflowPost(n *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children.

func (*RuleRequiredActions) VisitWorkflowPre added in v1.13.0

func (rule *RuleRequiredActions) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleRunnerLabel

type RuleRunnerLabel struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleRunnerLabel is a rule to check runner label like "ubuntu-latest". There are two types of runners, GitHub-hosted runner and Self-hosted runner. GitHub-hosted runner is described at https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners . And Self-hosted runner is described at https://docs.github.com/en/actions/hosting-your-own-runners/using-self-hosted-runners-in-a-workflow .

func NewRuleRunnerLabel

func NewRuleRunnerLabel() *RuleRunnerLabel

NewRuleRunnerLabel creates new RuleRunnerLabel instance.

func (*RuleRunnerLabel) VisitJobPre

func (rule *RuleRunnerLabel) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

type RuleShellName

type RuleShellName struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleShellName is a rule to check 'shell' field. For more details, see https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell

func NewRuleShellName

func NewRuleShellName() *RuleShellName

NewRuleShellName creates new RuleShellName instance.

func (*RuleShellName) VisitJobPost

func (rule *RuleShellName) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RuleShellName) VisitJobPre

func (rule *RuleShellName) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleShellName) VisitStep

func (rule *RuleShellName) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RuleShellName) VisitWorkflowPre

func (rule *RuleShellName) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleShellcheck

type RuleShellcheck struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleShellcheck is a rule to check shell scripts at 'run:' using shellcheck. https://github.com/koalaman/shellcheck

func NewRuleShellcheck

func NewRuleShellcheck(executable string, proc *concurrentProcess) (*RuleShellcheck, error)

NewRuleShellcheck creates new RuleShellcheck instance. The executable argument can be command name or relative/absolute file path. When the given executable is not found in system, it returns an error as 2nd return value.

func (*RuleShellcheck) VisitJobPost

func (rule *RuleShellcheck) VisitJobPost(n *Job) error

VisitJobPost is callback when visiting Job node after visiting its children.

func (*RuleShellcheck) VisitJobPre

func (rule *RuleShellcheck) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleShellcheck) VisitStep

func (rule *RuleShellcheck) VisitStep(n *Step) error

VisitStep is callback when visiting Step node.

func (*RuleShellcheck) VisitWorkflowPost

func (rule *RuleShellcheck) VisitWorkflowPost(n *Workflow) error

VisitWorkflowPost is callback when visiting Workflow node after visiting its children.

func (*RuleShellcheck) VisitWorkflowPre

func (rule *RuleShellcheck) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type RuleWorkflowCall

type RuleWorkflowCall struct {
	RuleBase
	// contains filtered or unexported fields
}

RuleWorkflowCall is a rule checker to check workflow call at jobs.<job_id>.

func NewRuleWorkflowCall

func NewRuleWorkflowCall(workflowPath string, cache *LocalReusableWorkflowCache) *RuleWorkflowCall

NewRuleWorkflowCall creates a new RuleWorkflowCall instance. 'workflowPath' is a file path to the workflow which is relative to a project root directory or an absolute path.

func (*RuleWorkflowCall) VisitJobPre

func (rule *RuleWorkflowCall) VisitJobPre(n *Job) error

VisitJobPre is callback when visiting Job node before visiting its children.

func (*RuleWorkflowCall) VisitWorkflowPre

func (rule *RuleWorkflowCall) VisitWorkflowPre(n *Workflow) error

VisitWorkflowPre is callback when visiting Workflow node before visiting its children.

type Runner

type Runner struct {
	// Expression supplies labels or a complete runner selection mapping.
	Expression *String
	// Labels is list label names to select a runner to run a job. There are preset labels and user
	// defined labels. Runner matching to the labels is selected.
	Labels []*String
	// LabelsExpr is a string when expression syntax ${{ }} is used for this section. Related issue is #164.
	LabelsExpr *String
	// Group is a group of runners specified in runs-on: section. It is nil when no group is specified.
	// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-runners-in-a-group
	Group *String
}

Runner is struct for runner configuration. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on

type ScheduleEntry

type ScheduleEntry struct {
	// Cron is the cron string for the schedule.
	Cron *String
	// Timezone is the optional IANA timezone for the schedule.
	Timezone *String
}

ScheduleEntry is a single entry in a schedule event. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onschedule

type ScheduledEvent

type ScheduledEvent struct {
	// Schedules is list of schedule entries which schedule the workflow.
	Schedules []*ScheduleEntry
	// Pos is a position in source.
	Pos *Pos
}

ScheduledEvent is event scheduled by workflow. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#scheduled-events

func (*ScheduledEvent) EventName

func (e *ScheduledEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type SelfHostedRunnerConfig added in v1.15.0

type SelfHostedRunnerConfig struct {
	// Labels lists additional self-hosted runner labels accepted in `runs-on`.
	//
	// For example, `[linux.2xlarge, custom-*]` accepts that label and matching custom labels.
	// Patterns use Go `path.Match` syntax. Omit this key, use `null`, or use `[]` to add no labels.
	Labels []string `yaml:"labels" jsonschema:"nullable"`
}

SelfHostedRunnerConfig is configuration for self-hosted runners.

type Service

type Service struct {
	// Name is name of the service.
	Name *String
	// Container is configuration of container which runs the service.
	Container *Container
}

Service is configuration to run a service like database. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idservices

type Services

type Services struct {
	// Value is a mapping from service ID to its Service instances. Keys are in lower case since
	// they are case-insensitive.
	Value map[string]*Service
	// Expression is an expression assigned to the services mapping by ${{ }} placeholder. Otherwise
	// this field is nil.
	Expression *String
	// Pos is a position in source.
	Pos *Pos
}

Services is a mapping from service ID to its configuration. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idservices

type Snapshot

type Snapshot struct {
	// Expression supplies an image name or complete snapshot mapping.
	Expression *String
	// ImageName is a name of the custom image.
	ImageName *String
	// Version is a version of the custom image.
	Version *String
	// If is a condition whether the custom image is used.
	If *String
}

Snapshot is a struct to represent image snapshot at jobs.<job_id>.snapshot. https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idsnapshot https://docs.github.com/en/actions/how-tos/manage-runners/larger-runners/use-custom-images

type Strategy

type Strategy struct {
	// Expression supplies the complete strategy mapping.
	Expression *String
	// Matrix is matrix of combinations of values. Each combination will run the job once.
	Matrix *Matrix
	// FailFast is flag to show if other jobs should stop when one job fails.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategyfail-fast
	FailFast *Bool
	// MaxParallel is how many jobs should be run at once.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymax-parallel
	MaxParallel *Int
	// Pos is a position in source.
	Pos *Pos
}

Strategy is strategy configuration of how the job is run. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy

type String

type String struct {
	// Value is a raw value of the string.
	Value string
	// Quoted represents the string is quoted with ' or " in the YAML source.
	Quoted bool
	// Pos is a position of the string in source.
	Pos *Pos
}

String represents generic string value in YAML file with position.

func (*String) ContainsExpression

func (s *String) ContainsExpression() bool

ContainsExpression returns whether the string contains at least one ${{ }} expression.

func (*String) IsExpressionAssigned

func (s *String) IsExpressionAssigned() bool

IsExpressionAssigned returns whether a single expression is assigned to the string.

type StringNode

type StringNode struct {
	// Value is value of the string literal. Escapes are resolved and quotes at both edges are
	// removed.
	Value string
	// contains filtered or unexported fields
}

StringNode is node for string literal.

func (*StringNode) Token

func (n *StringNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type StringType

type StringType struct{}

StringType is type for string values.

func (StringType) Assignable

func (ty StringType) Assignable(other ExprType) bool

Assignable returns if other type can be assignable to the type.

func (StringType) DeepCopy

func (ty StringType) DeepCopy() ExprType

DeepCopy duplicates itself. All its child types are copied recursively.

func (StringType) Merge

func (ty StringType) Merge(other ExprType) ExprType

Merge merges other type into this type. When other type conflicts with this type, the merged result is any type as fallback.

func (StringType) String

func (ty StringType) String() string

type SuppressionsPolicy added in v1.17.0

type SuppressionsPolicy struct {
	// contains filtered or unexported fields
}

SuppressionsPolicy controls whether inline exceptions may hide cache policy findings. Its YAML representation is a boolean or a rules/report mapping. A nil pointer or zero value permits inline suppressions. Use DisallowSuppressions to construct an enabled policy.

func DisallowSuppressions added in v1.17.0

func DisallowSuppressions(report string, rules ...string) (*SuppressionsPolicy, error)

DisallowSuppressions enables restrictions with report set to "suppression", "violation", or "all". With no rule IDs, it applies to all suppressible rules. It rejects unknown report values and rule IDs, removes duplicate IDs, and owns a copy of the selection. Assign the result to Config.Policy.DisallowSuppressions.

func (*SuppressionsPolicy) Enabled added in v1.17.0

func (p *SuppressionsPolicy) Enabled() bool

Enabled reports whether inline suppression restrictions are enabled. Nil and zero-value policies return false.

func (*SuppressionsPolicy) Report added in v1.17.0

func (p *SuppressionsPolicy) Report() string

Report returns "suppression", "violation", or "all", or an empty string when the policy is disabled.

func (*SuppressionsPolicy) Rules added in v1.17.0

func (p *SuppressionsPolicy) Rules() []string

Rules returns a copy of the explicit rule selection. Nil means all suppressible rules when Enabled is true, or no restriction when Enabled is false.

func (*SuppressionsPolicy) UnmarshalYAML added in v1.17.0

func (p *SuppressionsPolicy) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler. Each successful decode replaces the previous rule selection and reporting mode.

type Token

type Token struct {
	// Kind is kind of the token.
	Kind TokenKind
	// Value is string representation of the token.
	Value string
	// Offset is byte offset of token string starting.
	Offset int
	// Line is line number of start position of the token. Note that this value is 1-based.
	Line int
	// Column is column number of start position of the token. Note that this value is 1-based.
	Column int
}

Token is a token lexed from expression syntax. For more details, see https://docs.github.com/en/actions/learn-github-actions/expressions

func (*Token) String

func (t *Token) String() string

type TokenKind

type TokenKind int

TokenKind is kind of token.

const (
	// TokenKindUnknown is a default value of token as unknown token value.
	TokenKindUnknown TokenKind = iota
	// TokenKindEnd is a token for end of token sequence. Sequence without this
	// token means invalid.
	TokenKindEnd
	// TokenKindIdent is a token for identifier.
	TokenKindIdent
	// TokenKindString is a token for string literals.
	TokenKindString
	// TokenKindInt is a token for integers including hex integers.
	TokenKindInt
	// TokenKindFloat is a token for float numbers.
	TokenKindFloat
	// TokenKindLeftParen is a token for '('.
	TokenKindLeftParen
	// TokenKindRightParen is a token for ')'.
	TokenKindRightParen
	// TokenKindLeftBracket is a token for '['.
	TokenKindLeftBracket
	// TokenKindRightBracket is a token for ']'.
	TokenKindRightBracket
	// TokenKindDot is a token for '.'.
	TokenKindDot
	// TokenKindNot is a token for '!'.
	TokenKindNot
	// TokenKindLess is a token for '<'.
	TokenKindLess
	// TokenKindLessEq is a token for '<='.
	TokenKindLessEq
	// TokenKindGreater is a token for '>'.
	TokenKindGreater
	// TokenKindGreaterEq is a token for '>='.
	TokenKindGreaterEq
	// TokenKindEq is a token for '=='.
	TokenKindEq
	// TokenKindNotEq is a token for '!='.
	TokenKindNotEq
	// TokenKindAnd is a token for '&&'.
	TokenKindAnd
	// TokenKindOr is a token for '||'.
	TokenKindOr
	// TokenKindStar is a token for '*'.
	TokenKindStar
	// TokenKindComma is a token for ','.
	TokenKindComma
)

func (TokenKind) String

func (t TokenKind) String() string

type UntrustedInputChecker

type UntrustedInputChecker struct {
	// contains filtered or unexported fields
}

UntrustedInputChecker is a checker to detect untrusted inputs in an expression syntax tree. This checker checks object property accesses, array index accesses, and object filters. And detects paths to untrusted inputs. Found errors are stored in this instance and can be get via Errs method.

Note: To avoid breaking the state of checking property accesses on nested property accesses like foo[aaa.bbb].bar, IndexAccessNode.Index must be visited before IndexAccessNode.Operand.

func NewUntrustedInputChecker

func NewUntrustedInputChecker(roots UntrustedInputSearchRoots) *UntrustedInputChecker

NewUntrustedInputChecker creates a new UntrustedInputChecker instance. The roots argument is a search tree which defines untrusted input paths as trees.

func (*UntrustedInputChecker) Errs

func (u *UntrustedInputChecker) Errs() []*ExprError

Errs returns errors detected by this checker. This method should be called after visiting all nodes in a syntax tree.

func (*UntrustedInputChecker) Init

func (u *UntrustedInputChecker) Init()

Init initializes a state of checker.

func (*UntrustedInputChecker) OnVisitEnd

func (u *UntrustedInputChecker) OnVisitEnd()

OnVisitEnd is a callback which should be called after visiting whole syntax tree. This callback is necessary to handle the case where an untrusted input access is at root of expression.

func (*UntrustedInputChecker) OnVisitNodeEnter

func (u *UntrustedInputChecker) OnVisitNodeEnter(n ExprNode)

func (*UntrustedInputChecker) OnVisitNodeLeave

func (u *UntrustedInputChecker) OnVisitNodeLeave(n ExprNode)

OnVisitNodeLeave is a callback which should be called on visiting node after visiting its children.

type UntrustedInputMap

type UntrustedInputMap struct {
	Name     string
	Parent   *UntrustedInputMap
	Children map[string]*UntrustedInputMap
}

UntrustedInputMap is a recursive map to match context object property dereferences. Root of this map represents each context names and their ancestors represent recursive properties.

func NewUntrustedInputMap

func NewUntrustedInputMap(name string, children ...*UntrustedInputMap) *UntrustedInputMap

NewUntrustedInputMap creates new instance of UntrustedInputMap. It is used for node of search tree of untrusted input checker. The name `*` matches an array element and is reached by an index access or an object filter. The name `**` matches any property name. A map which uses either name must have it as its only child.

func (*UntrustedInputMap) String

func (m *UntrustedInputMap) String() string

type UntrustedInputSearchRoots

type UntrustedInputSearchRoots map[string]*UntrustedInputMap

UntrustedInputSearchRoots is a list of untrusted inputs. It forms tree structure to detect untrusted inputs in nested object property access, array index access, and object filters efficiently. Each value of this map represents a root of the search so their names are context names.

func (UntrustedInputSearchRoots) AddRoot

AddRoot adds a new root to search for detecting untrusted input.

type VariableNode

type VariableNode struct {
	// Name is name of the variable
	Name string
	// contains filtered or unexported fields
}

VariableNode is node for variable access.

func (*VariableNode) Token

func (n *VariableNode) Token() *Token

Token returns the first token of the node. This method is useful to get position of this node.

type VisitExprNodeFunc

type VisitExprNodeFunc func(node, parent ExprNode, entering bool)

VisitExprNodeFunc is a visitor function for VisitExprNode(). The entering argument is set to true when it is called before visiting children. It is set to false when it is called after visiting children. It means that this function is called twice for the same node. The parent argument is the parent of the node. When the node is root, its parent is nil.

type Visitor

type Visitor struct {
	// contains filtered or unexported fields
}

Visitor visits syntax tree from root in depth-first order

func NewVisitor

func NewVisitor() *Visitor

NewVisitor creates Visitor instance

func (*Visitor) AddPass

func (v *Visitor) AddPass(p Pass)

AddPass adds new pass which is called on traversing a syntax tree

func (*Visitor) EnableDebug

func (v *Visitor) EnableDebug(w io.Writer)

EnableDebug enables debug output when non-nil io.Writer value is given. All debug outputs from visitor will be written to the writer.

func (*Visitor) Visit

func (v *Visitor) Visit(n *Workflow) error

Visit visits given syntax tree in depth-first order

type WebhookEvent

type WebhookEvent struct {
	// Hook is a name of the webhook event.
	Hook *String
	// Types is list of types of the webhook event. Only the types enumerated here will trigger
	// the workflow.
	Types []*String
	// Branches is 'branches' filter. This value is nil when it is omitted.
	Branches *WebhookEventFilter
	// BranchesIgnore is 'branches-ignore' filter. This value is nil when it is omitted.
	BranchesIgnore *WebhookEventFilter
	// Tags is 'tags' filter. This value is nil when it is omitted.
	Tags *WebhookEventFilter
	// TagsIgnore is 'tags-ignore' filter. This value is nil when it is omitted.
	TagsIgnore *WebhookEventFilter
	// Paths is 'paths' filter. This value is nil when it is omitted.
	Paths *WebhookEventFilter
	// PathsIgnore is 'paths-ignore' filter. This value is nil when it is omitted.
	PathsIgnore *WebhookEventFilter
	// Workflows is list of workflow names which are triggered by 'workflow_run' event.
	Workflows []*String
	// Pos is a position in source.
	Pos *Pos
}

WebhookEvent represents event type based on webhook events. Some events can't have 'types' field. Only 'push' and 'pull' events can have 'tags', 'tags-ignore', 'paths' and 'paths-ignore' fields. Only 'workflow_run' event can have 'workflows' field. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onevent_nametypes

func (*WebhookEvent) EventName

func (e *WebhookEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type WebhookEventFilter

type WebhookEventFilter struct {
	// Name is a name of filter such like 'branches', 'tags'
	Name *String
	// Values is a list of filter values.
	Values []*String
}

WebhookEventFilter is a filter for Webhook events such as 'branches', 'paths-ignore', ... Webhook events are filtered by those filters. Some filters are exclusive. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#using-filters

func (*WebhookEventFilter) IsEmpty

func (f *WebhookEventFilter) IsEmpty() bool

IsEmpty returns true when it has no value. This may mean the WebhookEventFilter instance itself is nil.

type Workflow

type Workflow struct {
	// Name is name of the workflow. This field can be nil when user didn't specify the name explicitly.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#name
	Name *String
	// Description describes the workflow or reusable workflow.
	Description *String
	// RunName is the name of workflow runs. This field can be set dynamically using ${{ }}.
	// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#run-name
	RunName *String
	// On is list of events which can trigger this workflow.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onpushpull_requestbranchestags
	On []Event
	// Permissions is configuration of permissions of this workflow.
	Permissions *Permissions
	// CacheMode sets default cache access. Nil leaves the trigger-dependent default in effect.
	CacheMode *CacheMode
	// Env is a default set of environment variables while running this workflow.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#env
	Env *Env
	// Defaults is default configuration of how to run scripts.
	Defaults *Defaults
	// Concurrency is concurrency configuration of entire workflow. Each jobs also can their own
	// concurrency configurations.
	Concurrency *Concurrency
	// Jobs is mappings from job ID to the job object. Keys are in lower case since they are case-insensitive.
	Jobs map[string]*Job
}

Workflow is root of workflow syntax tree, which represents one workflow configuration file. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions

func (*Workflow) FindWorkflowCallEvent

func (w *Workflow) FindWorkflowCallEvent() (*WorkflowCallEvent, bool)

FindWorkflowCallEvent returns workflow_call event node if exists

type WorkflowCall

type WorkflowCall struct {
	// Uses is a workflow specification to be called. This field is mandatory.
	Uses *String
	// Inputs is a map from input name to input value at 'with:'. Keys are in lower case since input names
	// are case-insensitive.
	Inputs map[string]*WorkflowCallInput
	// Secrets is a map from secret name to secret value at 'secrets:'. Keys are in lower case since input
	// names are case-insensitive.
	Secrets map[string]*WorkflowCallSecret
	// InheritSecrets is true when 'secrets: inherit' is specified. In this case, Secrets must be empty.
	// https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecretsinherit
	InheritSecrets bool
}

WorkflowCall is a struct to represent workflow call at jobs.<job_id>. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses

type WorkflowCallEvent

type WorkflowCallEvent struct {
	// Inputs is an array of inputs of the workflow_call event. This value is not a map unlike other fields of this
	// struct since its order is important when checking the default values of inputs.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
	Inputs []*WorkflowCallEventInput
	// Secrets is a map from name of secret to secret configuration. When 'secrets' is omitted, nil is set to this
	// field. Keys are in lower case since they are case-insensitive.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets
	Secrets map[string]*WorkflowCallEventSecret
	// Outputs is a map from name of output to output configuration. Keys are in lower case since they are case-insensitive.
	// https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-outputs-from-a-reusable-workflow
	Outputs map[string]*WorkflowCallEventOutput
	// Pos is a position in source.
	Pos *Pos
}

WorkflowCallEvent is workflow_call event configuration. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow-reuse-events

func (*WorkflowCallEvent) EventName

func (e *WorkflowCallEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type WorkflowCallEventInput

type WorkflowCallEventInput struct {
	// Name is a name of the input.
	Name *String
	// Description is a description of the input.
	Description *String
	// Default is a default value of the input. Nil means no default value.
	Default *String
	// Required represents if the input is required or optional. When this value is nil, it was not explicitly specified.
	// In the case the default value is 'not required'.
	Required *Bool
	// Type of the input, which must be one of 'boolean', 'number' or 'string'. This property is required.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype
	Type WorkflowCallEventInputType
	// ID is an ID of the input. Input ID is in lower case because it is case-insensitive.
	ID string
}

WorkflowCallEventInput is an input configuration of workflow_call event. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs

func (*WorkflowCallEventInput) IsRequired

func (i *WorkflowCallEventInput) IsRequired() bool

IsRequired returns if the input is marked as required or not. require

type WorkflowCallEventInputType

type WorkflowCallEventInputType uint8

WorkflowCallEventInputType is a type of inputs at workflow_call event. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinput_idtype

const (
	// WorkflowCallEventInputTypeInvalid represents invalid type input as default value of the type.
	WorkflowCallEventInputTypeInvalid WorkflowCallEventInputType = iota
	// WorkflowCallEventInputTypeBoolean represents boolean type input.
	WorkflowCallEventInputTypeBoolean
	// WorkflowCallEventInputTypeNumber represents number type input.
	WorkflowCallEventInputTypeNumber
	// WorkflowCallEventInputTypeString represents string type input.
	WorkflowCallEventInputTypeString
)

type WorkflowCallEventOutput

type WorkflowCallEventOutput struct {
	// Name is a name of the output.
	Name *String
	// Description is a description of the output.
	Description *String
	// Value is an expression for the value of the output.
	Value *String
}

WorkflowCallEventOutput is an output configuration of workflow_call event. https://docs.github.com/en/actions/using-workflows/reusing-workflows#using-outputs-from-a-reusable-workflow

type WorkflowCallEventSecret

type WorkflowCallEventSecret struct {
	// Name is a name of the secret.
	Name *String
	// Description is a description of the secret.
	Description *String
	// Required represents if the secret is required or optional. When this value is nil, it means optional.
	// https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecretssecret_idrequired
	Required *Bool
}

WorkflowCallEventSecret is a secret configuration of workflow_call event. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callsecrets

type WorkflowCallInput

type WorkflowCallInput struct {
	// Name is a name of the input.
	Name *String
	// Value is a value of the input.
	Value *String
}

WorkflowCallInput is a normal input for workflow call.

type WorkflowCallSecret

type WorkflowCallSecret struct {
	// Name is a name of the secret
	Name *String
	// Value is a value of the secret
	Value *String
}

WorkflowCallSecret is a secret input for workflow call. https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idwith

type WorkflowDispatchEvent

type WorkflowDispatchEvent struct {
	// Inputs is map from input names to input attributes. Keys are in lower case since they are case insensitive.
	Inputs map[string]*DispatchInput
	// Pos is a position in source.
	Pos *Pos
}

WorkflowDispatchEvent is event on dispatching workflow manually. https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#workflow_dispatch

func (*WorkflowDispatchEvent) EventName

func (e *WorkflowDispatchEvent) EventName() string

EventName returns name of the event to trigger this workflow.

type WorkflowDispatchEventInputType

type WorkflowDispatchEventInputType uint8

WorkflowDispatchEventInputType is a type for input types of workflow_dispatch events. https://github.blog/changelog/2021-11-10-github-actions-input-types-for-manual-workflows/

const (
	// WorkflowDispatchEventInputTypeNone represents no type is specified to the input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeNone WorkflowDispatchEventInputType = iota
	// WorkflowDispatchEventInputTypeString is string type of input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeString
	// WorkflowDispatchEventInputTypeNumber is number type of input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeNumber
	// WorkflowDispatchEventInputTypeBoolean is boolean type of input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeBoolean
	// WorkflowDispatchEventInputTypeChoice is choice type of input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeChoice
	// WorkflowDispatchEventInputTypeEnvironment is environment type of input of workflow_dispatch event.
	WorkflowDispatchEventInputTypeEnvironment
)

Directories

Path Synopsis
cmd
actionlint command
internal
conformance
Package conformance loads the pinned upstream test corpora without extracting or executing their code.
Package conformance loads the pinned upstream test corpora without extracting or executing their code.
scripts
bump-version command
check-checks command
check-readme command
check-readme keeps the demo section of README.md in sync with the fixture it describes.
check-readme keeps the demo section of README.md in sync with the fixture it describes.
generate-config-schema command
Generate an editor schema from the configuration types and their Go comments.
Generate an editor schema from the configuration types and their Go comments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL