mcpField
G
github-script

github-script

github.com/githubDevelopment5.5k58 installsUpdated today
Repository

About github-script

A skill with guidelines for writing and checking JavaScript used in `actions/github-script@v8`. It is intended for developers maintaining GitHub Actions scripts and covers logging, inputs, outputs, summaries, errors, typing, and validation commands.

Key features

  1. 01Logging through `@actions/core`
  2. 02Reading inputs and setting outputs
  3. 03Writing step summaries
  4. 04Handling errors and types
  5. 05Typecheck, lint, and format commands

Use cases

  1. 01Adding input and output handling to an action script
  2. 02Writing a Markdown step summary
  3. 03Reporting script failures consistently
  4. 04Checking TypeScript and formatting changes

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/github/gh-aw --skill github-script

After installing, type/github-scriptin Claude Code to confirm it loaded.

Details

From the project README

GitHub Action Script Best Practices

Use these guidelines for JavaScript executed by actions/github-script@v8.

Important Notes

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
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.

Comments

Markdown supported