
Security News
GitHub Actions Pricing Whiplash: Self-Hosted Actions Billing Change Postponed
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.
@octokit/action
Advanced tools
GitHub API client for GitHub Actions
| Browsers |
|
|---|---|
| Node |
Install with
|
[!IMPORTANT] As we use conditional exports, you will need to adapt your
tsconfig.jsonby setting"moduleResolution": "node16", "module": "node16".See the TypeScript docs on package.json "exports".
See this helpful guide on transitioning to ESM from @sindresorhus
You can pass secret.GITHUB_TOKEN or any of your own secrets to a Node.js script. For example
name: My Node Action
on:
- pull_request
jobs:
my-action:
runs-on: ubuntu-latest
steps:
# Check out code using git
- uses: actions/checkout@v4
# Install Node 20
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install @octokit/action
# Node.js script can be anywhere. A good convention is to put local GitHub Actions
# into the `.github/actions` folder
- run: node .github/actions/my-script.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Setting GITHUB_TOKEN on either with: or env: will work.
// .github/actions/my-script.js
import { Octokit } from "@octokit/action";
const octokit = new Octokit();
// `octokit` is now authenticated using GITHUB_TOKEN
import { Octokit } from "@octokit/action";
const octokit = new Octokit();
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
// See https://developer.github.com/v3/issues/#create-an-issue
const { data } = await octokit.request("POST /repos/{owner}/{repo}/issues", {
owner,
repo,
title: "My test issue",
});
console.log("Issue created: %s", data.html_url);
You can also use octokit.issues.create({ owner, repo, title }). See the REST endpoint methods plugin for a list of all available methods.
import { Octokit } from "@octokit/action";
const octokit = new Octokit();
const eventPayload = require(process.env.GITHUB_EVENT_PATH);
const repositoryId = eventPayload.repository.node_id;
const response = await octokit.graphql(
`
mutation($repositoryId:ID!, $title:String!) {
createIssue(input:{repositoryId: $repositoryId, title: $title}) {
issue {
number
}
}
}
`,
{
repositoryId,
title: "My test issue",
},
);
@octokit/action is build upon @octokit/core. Refer to its README for the full API documentation.
Types for endpoint method parameters and responses are exported as RestEndpointMethodTypes. They keys are the same as the endpoint methods. Here is an example to retrieve the parameter and response types for octokit.checks.create()
import { RestEndpointMethodTypes } from `@octokit/action`;
type ChecksCreateParams =
RestEndpointMethodTypes["checks"]["create"]["parameters"];
type ChecksCreateResponse =
RestEndpointMethodTypes["checks"]["create"]["response"];
If you use self-hosted runners and require a proxy server to access internet resources then you will need to ensure that you have correctly configured the runner for proxy servers. @octokit/action will pick up the configured proxy server environment variables and configure @octokit/core with the correct request.dispatcher using ProxyAgent. If you need to supply a different request.dispatcher then you should ensure that it handles proxy servers if needed.
@octokit/action is simply a @octokit/core constructor, pre-authenticate using @octokit/auth-action.
The source code is … simple: src/index.ts.
FAQs
GitHub API client for GitHub Actions
The npm package @octokit/action receives a total of 38,520 weekly downloads. As such, @octokit/action popularity was classified as popular.
We found that @octokit/action demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
GitHub postponed a new billing model for self-hosted Actions after developer pushback, but moved forward with hosted runner price cuts on January 1.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.