Skip to content
Latchkey

actions/github-script: Run JavaScript Against the GitHub API

github-script runs inline JavaScript with an authenticated Octokit, context, and core helpers.

Skip writing a custom action for one-off API calls. github-script gives you github (Octokit), context, core, and exec in a single step.

Key inputs (with:)

  • script: the JavaScript body to run (required).
  • github-token: token for API calls (defaults to GITHUB_TOKEN).
  • result-encoding: string or json for the step output.
  • retries: automatic retries on API failures.

Example workflow

.github/workflows/ci.yml
jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              body: 'Build started on ${{ runner.os }}.'
            })

On any runner

github-script runs on any runner. Latchkey managed runners run it unchanged.

Key takeaways

  • github is a pre-authenticated Octokit client.
  • context exposes repo, issue, and event payload data.
  • Great for PR comments, labels, and small automations.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →