Labsco
github logo

github-script

✓ Official4,700

by github · part of github/gh-aw

Best practices for writing JavaScript code for GitHub Actions using github-script

🔥🔥🔥✓ VerifiedFreeQuick setup
🧰 Not standalone. This skill ships with github/gh-aw and only works together with that tool — install the tool first, then add this skill.

This is the playbook your agent receives when the skill activates — you don't need to read it to use the skill, but it's here to audit before installing.


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

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()

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.