github-script
3
总安装量
3
周安装量
#60452
全站排名
安装命令
npx skills add https://github.com/kjanat/skills --skill github-script
Agent 安装分布
opencode
3
gemini-cli
3
claude-code
3
github-copilot
3
codex
3
kimi-cli
3
Skill 文档
github-script
Use for authoring or reviewing uses: actions/github-script@v8 workflow steps.
with.script runs as an async function body; use await import(...) for module imports.
Defaults
- Pin
actions/github-script@v8 - Runtime is Node 24
- Self-hosted runner minimum is
v2.327.1 - Prefer
github.rest.*endpoint methods; usegithub.request(...)for raw requests. - Prefer ESM modules (
.mjsor.jswith// @ts-check); avoid CommonJS (require,module.exports). - If authoring helpers in TypeScript, compile to
.mjs/.jsand import the built file in workflow steps.
Fast workflow
- Define step
idif downstream steps need outputs. - Prefer
contextandcontext.payloadfor event data already provided. - Pass only missing values through
env. - Keep inline script tiny; delegate logic to external ESM file.
- Read env values via
process.envinside module only when needed. - Use
github.rest.*,github.graphql, orgithub.request. - Return value only when output needed.
- Configure retries for flaky API calls.
ESM-first architecture
- Inline
scriptshould usually do one thing:import+ call exported function. - Put reusable logic in
scripts/*.mjsmodules. - Share logic across workflows via one core module + small entry modules.
- Typecheck modules locally (enable
checkJsintsconfig.jsonor add// @ts-checkfor JS). - For
.tssource files, keep runtime imports pointed at compiled JS outputs.
See references/external-files.md for patterns.
Reading order
| Task | Read |
|---|---|
| Write new step | SKILL.md, references/external-files.md, references/examples.md, references/security.md |
| Review existing step | SKILL.md, references/security.md, references/inputs-outputs-retries.md |
| Migrate old workflow | SKILL.md, references/runtime-and-migrations.md |
Security rules
- Never inline
${{ ... }}expressions directly insidescript. - Expressions are evaluated before script; direct interpolation can cause injection or invalid JavaScript.
- If value exists in
context, use it there; do not mirror intoenv. - Use
envboundary and parse/validate in script.
See references/security.md for patterns.
Script arguments available in script body
github: authenticated Octokit client with pagination pluginsoctokit: alias forgithubcontext: workflow run contextcore,glob,io,exec- wrapped
requireplus escape hatch__original_require__(legacy; prefer ESMimport)
If you need source-level API details, inspect the action repo: https://github.com/actions/github-script (for example action.yml, types/async-function.d.ts, src/main.ts).
This action (upstream model)
with.script is the body of an async function. These values are pre-defined (no import needed):
github: pre-authenticated octokit/rest.js clientcontext: workflow run contextcore: @actions/coreglob: @actions/globio: @actions/ioexec: @actions/execrequire: wrapped Node require (cwd-relative + local npm packages); use__original_require__for unwrapped require
Output model
- Function return value becomes
steps.<id>.outputs.result - Default result encoding is JSON
- Use
result-encoding: stringfor raw string output
Retry model
- Enable retries with
retries: <n> - Default retry-exempt status codes:
400,401,403,404,422 - Override with
retry-exempt-status-codes
See references/inputs-outputs-retries.md for details.
Token model
- Default token is the action’s
github-tokeninput default (typically workflow token, repo-scoped) - Use
github-tokenwith PAT secret for cross-repo or broader scopes
In this reference
| File | Purpose |
|---|---|
references/security.md |
injection avoidance and env-boundary patterns |
references/inputs-outputs-retries.md |
inputs, outputs, retry semantics |
references/runtime-and-migrations.md |
v5-v8 changes and upgrade checks |
references/external-files.md |
external ESM architecture, reuse, typecheck |
references/examples.md |
minimal templates for common tasks |
Scope note
Upstream repository currently does not accept general contributions.
Security fixes and major breakage fixes still maintained.