mcpField
A
actionlint

actionlint

github.com/rshade测试与质量392 次安装2 周前更新
代码仓库

关于 actionlint

actionlint 是一项使用 actionlint 命令行工具检查 GitHub Actions 工作流文件的技能,可发现语法、引用、表达式、Shell 和安全问题,并分类报告错误及修复建议。

主要功能

  1. 01检查工作流语法和引用
  2. 02发现表达式与 Shell 错误
  3. 03标记安全问题
  4. 04使用项目或默认配置
  5. 05分类报告错误和修复建议

适用场景

  1. 01合并变更前验证所有工作流
  2. 02检查指定的工作流文件
  3. 03通过标准输入检查生成的工作流

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/rshade/agent-skills --skill actionlint

安装后在 Claude Code 中输入/actionlint确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

evals/
evals.json
test-workflow.yml
references/
actionlint-config.yaml
actionlint-rules.md

详细介绍

Actionlint

验证 GitHub Actions 工作流文件(.github/workflows/*.yml)是否存在语法错误、无效引用、表达式错误和安全问题。捕获那些原本只能在运行时才会出现的错误。

此技能的功能

  1. 检查 actionlint 是否可用;如果缺少,则指导安装。
  2. 检测项目专用的 .actionlintrc.yaml,如果不存在,则使用合理的默认配置。
  3. 验证工作流文件中的语法、Action 引用、表达式、Shell 脚本和安全问题。
  4. 按具体规则类别报告错误并提供修复方法。

安装检查

actionlint --version 2>/dev/null

如果尚未安装,请使用以下任一方式安装:

# Go (requires Go 1.22+)
go install github.com/rhysd/actionlint/cmd/actionlint@latest

# Homebrew (macOS/Linux)
brew install actionlint

# Download binary (Linux amd64)
curl -sL "$(curl -sL https://api.github.com/repos/rhysd/actionlint/releases/latest \
  | grep browser_download_url | grep linux_amd64.tar.gz | cut -d'"' -f4)" \
  | tar xz -C /usr/local/bin actionlint

如果安装失败,请停止并报告问题,同时提供解决步骤。 不要悄悄跳过验证。

可选增强:如果已安装 shellcheck,actionlint 会自动验证 run: 块中的 Shell 脚本。建议安装,但并非必需。

配置检测优先级

  1. 项目根目录中的 .actionlintrc.yaml
  2. 默认配置(参见 references/actionlint-config.yaml)

如果项目中不存在配置,请在运行验证前,使用 references 中的默认配置创建一个临时 .actionlintrc.yaml。

验证工作流

1. Check actionlint installation
   ├─ Installed → continue
   └─ Missing → install, then continue (fail if install fails)

2. Detect project config
   ├─ Found → use it
   └─ Not found → use default config from references/

3. Run validation
   ├─ All workflows:
   │    actionlint
   ├─ Specific files:
   │    actionlint .github/workflows/ci.yml
   └─ With config:
        actionlint -config-file .actionlintrc.yaml

4. Report results
   ├─ Valid → confirm and proceed
   └─ Invalid → show errors, suggest fixes, re-validate after correction

验证方式

验证所有工作流文件(自动发现 .github/workflows/)
actionlint
验证指定文件
actionlint .github/workflows/ci.yml .github/workflows/release.yml
使用显式配置验证
actionlint -config-file .actionlintrc.yaml
从标准输入验证(适用于生成的工作流)
cat workflow.yml | actionlint -

错误处理

安装失败

如果无法安装 actionlint,请报告错误并提供解决步骤。不要继续验证。

验证失败

验证失败时,请针对每个错误报告以下信息:

  • 文件和行号
  • 错误类别(语法、Action、表达式、运行器、Shell 等)
  • 错误原因
  • 具体的修复方法

示例:

Validation failed:

1. .github/workflows/ci.yml:15:9
   action "actions/checkout@master" — use a commit hash or version tag
   Fix: actions/checkout@v4

2. .github/workflows/ci.yml:23:14
   expression error: property "repo" not defined in "github" context
   Fix: use "github.repository" instead of "github.repo"

3. .github/workflows/deploy.yml:8:5
   "push" event does not support "paths" filter with "tags" filter
   Fix: split into separate workflows or remove one filter

报告错误后,请建议修复方法,并在修正后重新验证。

规则参考

完整的规则参考、常见错误类别、安全检查和修复示例,请参见 references/actionlint-rules.md。

评论

支持 Markdown