github-script
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.
More from kjanat/skills
changelog-writing
Write and maintain changelogs following the Keep a Changelog convention. Use when creating a CHANGELOG.md, adding entries for a release, or reviewing changelog format and completeness.
7index-knowledge
Generate hierarchical AGENTS.md knowledge base for a codebase. Creates root + complexity-scored subdirectory documentation.
6uv-versioning
Version bumping workflow for uv projects. Use when reading/updating package versions, planning release bump chains, or validating main vs workspace package bumps.
6github-service-containers
Configure Docker service containers (Redis, PostgreSQL, etc.) as sidecar services in GitHub Actions workflows for integration testing. Use when adding databases, caches, or message queues to CI workflows, or debugging service container networking and health checks.
6build-skill
Create effective skills for OpenCode agents. Load FIRST before writing any SKILL.md. Provides required format, naming conventions, progressive disclosure patterns, and validation. Use when building, reviewing, or debugging skills.
5threlte
Routes Threlte questions to exact, commit-pinned docs paths and practical workflows. Use when helping with setup, debugging, or architecture across @threlte/core, @threlte/extras, @threlte/gltf, @threlte/rapier, @threlte/theatre, @threlte/xr, @threlte/flex, and @threlte/studio.
1