Skip to main content

github-script

Write robust JavaScript for GitHub Actions github-script steps.

来源信息

仓库
github/gh-aw
最近来源活动
2026年5月12日 22:45
检测到的 SKILL.md 语言
英语
星标
5,200
分支
564

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
github-script
description
Write robust JavaScript for GitHub Actions github-script steps.
# GitHub Action Script Best Practices Use these guidelines for JavaScript executed by `actions/github-script@v8`. ## Important Notes - This action provides `@actions/core` and `@actions/github` packages globally - Do not add import or require for `@actions/core` - Reference documentation: - https://github.com/actions/toolkit/blob/main/packages/core/README.md - https://github.com/actions/toolkit/blob/main/packages/github/README.md ## Best Practices - Use `core.info`, `core.warning`, `core.error` for logging, not `console.log` or `console.error` - Use `core.setOutput` to set action outputs - Use `core.exportVariable` to set environment variables for subsequent steps - Use `core.getInput` to get action inputs, with `required: true` for mandatory inputs - Use `core.setFailed` to mark the action as failed with an error message ## Step Summary Use `core.summary.*` function to write output the step summary file. - Use `core.summary.addRaw()` to add raw Markdown content (GitHub Flavored Markdown supported) - Make sure to call `core.summary.write()` to flush pending writes - Summary function calls can be chained, e.g. `core.summary.addRaw(...).addRaw(...).write()` ## Common Errors - Avoid `any` type as much as possible, use specific types or `unknown` instead - Catch handler: check if error is an instance of Error before accessing message property ```js catch (error) { core.setFailed(error instanceof Error ? error : String(error)); } ``` - `core.setFailed` also calls `core.error`, so do not call both ## Typechecking Run `make js` to run the typescript compiler. Run `make lint-cjs` to lint the files. Run `make fmt-cjs` after editing to format the file.
在 GitHub 查看