Add Api to ActionState

This commit is contained in:
Michael B. Gale
2026-07-13 16:55:44 +01:00
parent 1542951d09
commit 2dbfdcaa83
2 changed files with 15 additions and 2 deletions

View File

@@ -1,8 +1,9 @@
import * as core from "@actions/core";
import { ActionsEnv, getActionsEnv } from "./actions-util";
import type { ApiClient } from "./api-client";
import { Env, ReadOnlyEnv } from "./environment";
import { FeatureEnablement } from "./feature-flags";
import type { FeatureEnablement } from "./feature-flags";
import { getActionsLogger, Logger } from "./logging";
import {
ActionName,
@@ -36,6 +37,10 @@ export interface FeatureState {
/** Access to Actions-related functionality. */
actions: ActionsEnv;
};
Api: {
/** A GitHub API client. */
apiClient: ApiClient;
};
FeatureFlags: {
/** Information about enabled feature flags. */
features: FeatureEnablement;

View File

@@ -193,7 +193,14 @@ export function getTestActionsEnv(): ActionsEnv {
}
/** For testing purposes, we make all available state features accessible in `TestEnv`. */
type AllState = ["Logger", "Env", "ReadOnlyEnv", "Actions", "FeatureFlags"];
type AllState = [
"Logger",
"Env",
"ReadOnlyEnv",
"Actions",
"Api",
"FeatureFlags",
];
/** Initialise a fresh `ActionState<AllState>` value. */
export function initAllState(
@@ -205,6 +212,7 @@ export function initAllState(
logger: new RecordingLogger(),
env: getTestEnv(),
actions: getTestActionsEnv(),
apiClient: github.getOctokit("123"),
features: createFeatures([]),
...overrides,
};