actions/github-script@v9
Run simple scripts using the GitHub client
At a glance
- Latest major
v9- Repository
- actions/github-script
- Inputs
- 9 (1 required)
- Outputs
- 1
- Runs using
node24- License
- MIT
- Last checked
Inputs and outputs come straight from the action's official action.yml. See our editorial standards.
Usage
- uses: actions/github-script@v9Inputs
| Name | Required | Default | Description |
|---|---|---|---|
script | Yes | none | The script to run |
github-token | No | ${{ github.token }} | The GitHub token used to create an authenticated client |
debug | No | ${{ runner.debug == '1' }} | Whether to tell the GitHub client to log details of its requests. true or false. Default is to run in debug mode when the GitHub Actions step debug logging is turned on. |
user-agent | No | actions/github-script | An optional user-agent string |
previews | No | none | A comma-separated list of GraphQL API previews to accept |
result-encoding | No | json | Either "string" or "json" (default "json")—how the result will be encoded |
retries | No | 0 | The number of times to retry a request |
retry-exempt-status-codes | No | 400,401,403,404,422 | A comma separated list of status codes that will NOT be retried e.g. "400,500". No effect unless `retries` is set |
base-url | No | none | An optional GitHub REST API URL to connect to a different GitHub instance. For example, https://my.github-enterprise-server.com/api/v3 |
Outputs
| Name | Description |
|---|---|
result | The return value of the script, stringified with `JSON.stringify` |
Read an output with ${{ steps.<step-id>.outputs.<name> }}; the step needs an id.
Examples
Comment on a pull request
Call the GitHub API in a few lines of JavaScript without a custom action.
name: Example
on:
pull_request:
permissions:
pull-requests: write
jobs:
example:
runs-on: ubuntu-latest
steps:
- name: GitHub Script
uses: actions/github-script@v9
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: 'Thanks for the PR!'
});Each example passed actionlint (syntax, expressions and the inputs it knows for this action). They were not run in a live repository, so replace placeholder values such as names, ARNs and paths with your own.
Something out of date or wrong? Report it on our Contact page. This page is rebuilt from the action's repository roughly once a week.