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
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…
peter-evans/create-pull-request: Open PRs from CIReference for peter-evans/create-pull-request: commit workflow-generated changes to a branch and open or upda…
actions/labeler: Auto-Label PRs by Changed PathsReference for actions/labeler: automatically apply labels to pull requests based on which files they touch, c…