An alternative to the official github-script action, with some additional features.
See action.yml.
- uses: silverlyra/[email protected]
with:
# JavaScript source to run (or a script filename)
script: >
console.log("Hello, world!");
# Input data to pass into your script
input: 'null'
# If "json", `input` will be parsed as JSON.
# If "string", your script will see the literal string value of `input`.
input-encoding: 'json'
# If "json", the script's return value will be JSON-encoded.
# If "string", the script's return value will be output as a string.
result-encoding: 'json'
# Directory to change into
cwd: '.'
github-token: ${{ github.token }}The JavaScript passed as the script input will have the following values predefined:
input: Theinputpassed to the action, viawith:env: An object containing all environment variables (process.env)github: A GitHub REST API client
Scripts also have access to some helper functions:
fetch: The fetch functionreadEvent: Read the GitHub event JSON file off of disk; return the eventnameand itsdatashell: Spawn a process and (optionally) capture its output
These packages are also available:
fs: The Node.js fs/promises modulepath: The Node.js path moduleartifact: The @actions/artifact NPM packagechalk: The chalk NPM packagecore: The @actions/core NPM packageexec: The @actions/exec NPM packageglob: The @actions/glob NPM packageio: The @actions/io NPM package