feat!: add getOctokit to script context, upgrade @actions/github v9, @octokit/core v7, and related packages#700
Merged
Merged
Conversation
salmanmkc
temporarily deployed
to
debug-integration-test
March 1, 2026 00:26 — with
GitHub Actions
Inactive
|
Hello from actions/github-script! (fe5245d) |
There was a problem hiding this comment.
Pull request overview
This PR exposes getOctokit in the github-script runtime context so user scripts can create additional authenticated Octokit clients (e.g., for multi-token workflows) without relying on require('@actions/github').
Changes:
- Passes
getOctokitinto the script execution context insrc/main.ts. - Extends the
AsyncFunctionArgumentsTypeScript type to includegetOctokitwith an Octokit-typed signature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/main.ts | Adds getOctokit to the object passed into callAsyncFunction so scripts can access it. |
| src/async-function.ts | Updates the script context type (AsyncFunctionArguments) to type getOctokit and imports Octokit types. |
Comments suppressed due to low confidence (2)
src/main.ts:71
getOctokitis being passed through directly from@actions/github, so any Octokit clients created inside the user script won’t automatically inherit this action’s configured defaults (e.g.,base-urlfor GHES,user-agentwith orchestration ID,retries/request options, and the installedretry/requestLogplugins). This can lead to surprising differences betweengithubandgetOctokit(...)behavior. Consider exposing a wrapper that pre-applies the same options/plugins by default (while still allowing callers to override/extend options/plugins when needed).
github,
octokit: github,
getOctokit,
context,
core,
src/async-function.ts:20
- This adds a new deep import from
@octokit/core/types, but the codebase already imports Octokit types via@octokit/core/dist-types/types(e.g.src/retry-options.ts). To stay consistent (and to reduce the risk of relying on a non-exported subpath), align the import path with the existing convention or derive the type directly from@actions/github(e.g., typegetOctokitastypeof import('@actions/github').getOctokit) so the signature can’t drift from the actual implementation.
import {GitHub} from '@actions/github/lib/utils'
import * as glob from '@actions/glob'
import * as io from '@actions/io'
import type {OctokitOptions, OctokitPlugin} from '@octokit/core/types'
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
export declare type AsyncFunctionArguments = {
context: Context
core: typeof core
github: InstanceType<typeof GitHub>
octokit: InstanceType<typeof GitHub>
getOctokit: (
token: string,
options?: OctokitOptions,
...additionalPlugins: OctokitPlugin[]
) => InstanceType<typeof GitHub>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
salmanmkc
temporarily deployed
to
debug-integration-test
March 1, 2026 01:30 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
March 9, 2026 11:47 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
March 9, 2026 11:52 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
March 9, 2026 12:02 — with
GitHub Actions
Inactive
pelikhan
approved these changes
Mar 9, 2026
salmanmkc
temporarily deployed
to
debug-integration-test
April 7, 2026 15:47 — with
GitHub Actions
Inactive
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 7, 2026 15:50
c7fb361 to
2fe016f
Compare
salmanmkc
temporarily deployed
to
debug-integration-test
April 7, 2026 15:50 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 7, 2026 16:08 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 20:41 — with
GitHub Actions
Inactive
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 8, 2026 20:44
1bdc919 to
7f52c47
Compare
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 20:44 — with
GitHub Actions
Inactive
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 8, 2026 20:48
7f52c47 to
95933be
Compare
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 20:48 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 21:39 — with
GitHub Actions
Inactive
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 8, 2026 21:41
47f6d8e to
7ece71c
Compare
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 21:41 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 8, 2026 21:46 — with
GitHub Actions
Inactive
getOctokit in script context for multi-token workflowscreateOctokit to script context for multi-token workflows
salmanmkc
temporarily deployed
to
debug-integration-test
April 9, 2026 08:00 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 9, 2026 08:55 — with
GitHub Actions
Inactive
createOctokit to script context for multi-token workflows
salmanmkc
temporarily deployed
to
debug-integration-test
April 9, 2026 09:03 — with
GitHub Actions
Inactive
salmanmkc
temporarily deployed
to
debug-integration-test
April 9, 2026 09:10 — with
GitHub Actions
Inactive
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 9, 2026 20:59
00e48dc to
6dd124c
Compare
ericsciple
previously approved these changes
Apr 9, 2026
salmanmkc
force-pushed
the
salmanmkc/expose-getoctokit
branch
from
April 9, 2026 21:02
6dd124c to
c108472
Compare
- Resolve integration.yml merge conflicts (user-agent assertions) - Fix OctokitOptions import path to @octokit/core/dist-types/types - Rebuild dist
ericsciple
previously approved these changes
Apr 9, 2026
The merge from main incorrectly used the v5 import path (@octokit/core/dist-types/types). v7 exports types via @octokit/core/types in its package.json exports map. Rebuild dist with correct dependency resolution.
ericsciple
approved these changes
Apr 9, 2026
sneha-krip
approved these changes
Apr 9, 2026
This was referenced May 18, 2026
This was referenced Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Upgrades
@actions/githubto v9 (and related Octokit packages) and addsgetOctokitto the script context.Today, if you need a second Octokit client with a different token (GitHub App, PAT, cross-org), you do something like:
That breaks in v9 because
@actions/githubis now ESM-only —require()no longer works. This PR replaces that pattern with a built-ingetOctokitthat's available directly in the script context, no imports needed:Works for GHES too:
The secondary client inherits retry settings, user-agent, proxy config, and plugins from the action — so it behaves consistently with the primary
githubclient.requestandretryoptions are deep-merged (so you can tweak one field without losing the rest), while other options likebaseUrloruserAgentreplace the default outright if you set them.Dependency upgrades
@actions/github@octokit/core@octokit/plugin-request-log@octokit/plugin-retryAlso updated
tsconfig.jsonto ES2022 with bundler module resolution, and added Jest tsconfig overrides for CJS test compatibility.Why v9
@actions/githubv6 → v9 brings updated Octokit types and the orchestration ID user-agent feature (toolkit#2364). The main breaking change is thatrequire('@actions/github')stops working inside scripts — workflows like MetaMask's that use this pattern will need to switch to the injectedgetOctokitinstead.Other breaking changes:
const getOctokit = ...orlet getOctokit = ...in scripts will SyntaxError (same asconst github = ...today — function parameters can't be redeclared with const/let). Use it directly or usevarif you really need to redeclare.@actions/githubimports (like@actions/github/lib/utils) may have changed paths.What's in the diff
New:
src/create-configured-getoctokit.ts— factory wrapper (deep merge, undefined stripping, plugin dedup)Changed:
src/main.ts— wires factory into script contextsrc/async-function.ts— v9 type imports,getOctokitin argument typessrc/retry-options.ts— updated import path for v9tsconfig.json— ES2022 + bundler resolutionpackage.json— version 9.0.0, dependency bumps.github/workflows/integration.yml— new getOctokit test job, user-agent test fixREADME.md— v9 docs, getOctokit section with examples, breaking changes.licenses/— refreshed for all upgraded packagesTesting
Part of https://github.com/github/c2c-actions/issues/10001
Also closes: #707