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@v9

Inputs

NameRequiredDefaultDescription
scriptYesnoneThe script to run
github-tokenNo${{ github.token }}The GitHub token used to create an authenticated client
debugNo${{ 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-agentNoactions/github-scriptAn optional user-agent string
previewsNononeA comma-separated list of GraphQL API previews to accept
result-encodingNojsonEither "string" or "json" (default "json")—how the result will be encoded
retriesNo0The number of times to retry a request
retry-exempt-status-codesNo400,401,403,404,422A comma separated list of status codes that will NOT be retried e.g. "400,500". No effect unless `retries` is set
base-urlNononeAn optional GitHub REST API URL to connect to a different GitHub instance. For example, https://my.github-enterprise-server.com/api/v3

Outputs

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