@actions/workflow-parser

中文文档
0.3.61发布于 2026/08/05MITTypeScriptES Module构建来源已验证近 30 天下载 20.7万

@actions/workflow-parser is a library to parse GitHub Actions workflows.

原始使用文档
文档目录8 节
  1. Installation
  2. Usage
  3. Simple example
  4. Contributing
  5. Build
  6. Test
  7. Lint
  8. License

actions/workflow-parser

@actions/workflow-parser is a library to parse GitHub Actions workflows.

Installation

The package contains TypeScript types and compiled ECMAScript modules.

npm install @actions/workflow-parser

Usage

The parser is driven by a custom schema defined in worflows-v1.0.json.

Simple example

parseWorkflow parses the workflow YAML into an intermediate representation and validates that it conforms to the schema. Any parsing errors are returned in the errors property of the result context.

var trace: TraceWriter;

const result = parseWorkflow(
  {
    name: "test.yaml",
    content: `on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - run: echo 'hello'`
  },
  trace
);

convertWorkflowTemplate then takes that intermediate representation and converts it to a WorkflowTemplate object, which is a more convenient representation for working with workflows.

const workflowTemplate = await convertWorkflowTemplate(result.context, result.value);

// workflowTemplate.jobs[0].id === "build"
// workflowTemplate.jobs[0].steps[0].run === "echo 'hello'"

Contributing

See CONTRIBUTING.md at the root of the repository for general guidelines and recommendations.

Similar to `actions/expressions, this project is just one of multiple implementations of the GitHub Actions workflow parser. We therefore cannot accept contributions that significantly modify the schema or the overall behavior of the parser. If you would like to propose changes to Actions itself, please use our Community Forum.

If you do want to contribute, please run prettier to format your code and add unit tests as appropriate before submitting your PR. ./testdata contains test cases that all implementations should pass, please also make sure those tests are still passing.

Build

npm run build

or to watch for changes

npm run watch

Test

npm test

or to watch for changes and run tests:

npm run test-watch

Lint

npm run format-check

License

This project is licensed under the terms of the MIT open source license. Please refer to MIT for the full terms.

版本与发布记录

@actions/workflow-parser 共发布 63 个版本,首次发布于 2023/03/24;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.61latest2026/08/053 个月前
0.3.602026/07/153 个月前
0.3.592026/07/143 个月前
0.3.582026/06/124 个月前
0.3.572026/05/125 个月前
0.3.562026/05/086 个月前

关于 @actions/workflow-parser 的常见问题

@actions/workflow-parser 是什么?

@actions/workflow-parser is a library to parse GitHub Actions workflows.

如何安装 @actions/workflow-parser?

在项目目录运行 npm install @actions/workflow-parser,或使用 pnpm add / yarn add / bun add。

@actions/workflow-parser 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@actions/workflow-parser 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@actions/workflow-parser 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@actions/workflow-parser 可以商用吗?

@actions/workflow-parser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@actions/workflow-parser 的下载量有多少?

根据 npm 官方下载统计,@actions/workflow-parser 在 2026/10/05 – 2026/11/03 这 30 天内被下载 207,004 次,日均约 6,900 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@actions/workflow-parser 还在维护吗?

最新版本 0.3.61 发布于 2026/08/05(3 个月前);至今共发布 63 个版本,其中过去 12 个月发布了 42 个;首次发布于 2023/03/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。