Skip to content

Commit 2dbfdca

Browse files
committed
Add Api to ActionState
1 parent 1542951 commit 2dbfdca

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/action-common.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as core from "@actions/core";
22

33
import { ActionsEnv, getActionsEnv } from "./actions-util";
4+
import type { ApiClient } from "./api-client";
45
import { Env, ReadOnlyEnv } from "./environment";
5-
import { FeatureEnablement } from "./feature-flags";
6+
import type { FeatureEnablement } from "./feature-flags";
67
import { getActionsLogger, Logger } from "./logging";
78
import {
89
ActionName,
@@ -36,6 +37,10 @@ export interface FeatureState {
3637
/** Access to Actions-related functionality. */
3738
actions: ActionsEnv;
3839
};
40+
Api: {
41+
/** A GitHub API client. */
42+
apiClient: ApiClient;
43+
};
3944
FeatureFlags: {
4045
/** Information about enabled feature flags. */
4146
features: FeatureEnablement;

src/testing-utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ export function getTestActionsEnv(): ActionsEnv {
193193
}
194194

195195
/** For testing purposes, we make all available state features accessible in `TestEnv`. */
196-
type AllState = ["Logger", "Env", "ReadOnlyEnv", "Actions", "FeatureFlags"];
196+
type AllState = [
197+
"Logger",
198+
"Env",
199+
"ReadOnlyEnv",
200+
"Actions",
201+
"Api",
202+
"FeatureFlags",
203+
];
197204

198205
/** Initialise a fresh `ActionState<AllState>` value. */
199206
export function initAllState(
@@ -205,6 +212,7 @@ export function initAllState(
205212
logger: new RecordingLogger(),
206213
env: getTestEnv(),
207214
actions: getTestActionsEnv(),
215+
apiClient: github.getOctokit("123"),
208216
features: createFeatures([]),
209217
...overrides,
210218
};

0 commit comments

Comments
 (0)