Convert secrets, complete secrets in called workflow
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import {DescriptionDictionary} from "@github/actions-expressions";
|
||||
import {WorkflowContext} from "../context/workflow-context";
|
||||
import {Mode} from "./default";
|
||||
|
||||
export type ContextProviderConfig = {
|
||||
getContext: (
|
||||
name: string,
|
||||
defaultContext: DescriptionDictionary | undefined,
|
||||
workflowContext: WorkflowContext
|
||||
workflowContext: WorkflowContext,
|
||||
mode: Mode
|
||||
) => Promise<DescriptionDictionary | undefined>;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ import {getJobContext} from "./job";
|
||||
import {getJobsContext} from "./jobs";
|
||||
import {getMatrixContext} from "./matrix";
|
||||
import {getNeedsContext} from "./needs";
|
||||
import {getSecretsContext} from "./secrets";
|
||||
import {getStepsContext} from "./steps";
|
||||
import {getStrategyContext} from "./strategy";
|
||||
|
||||
@@ -39,7 +40,7 @@ export async function getContext(
|
||||
continue;
|
||||
}
|
||||
|
||||
value = (await config?.getContext(contextName, value, workflowContext)) || value;
|
||||
value = (await config?.getContext(contextName, value, workflowContext, mode)) || value;
|
||||
|
||||
context.add(contextName, value, getDescription(RootContext, contextName));
|
||||
}
|
||||
@@ -81,11 +82,7 @@ function getDefaultContext(name: string, workflowContext: WorkflowContext, mode:
|
||||
});
|
||||
|
||||
case "secrets":
|
||||
return new DescriptionDictionary({
|
||||
key: "GITHUB_TOKEN",
|
||||
value: new data.StringData("***"),
|
||||
description: getDescription("secrets", "GITHUB_TOKEN")
|
||||
});
|
||||
return getSecretsContext(workflowContext, mode);
|
||||
|
||||
case "steps":
|
||||
return getStepsContext(workflowContext);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import {data, DescriptionDictionary} from "@github/actions-expressions";
|
||||
import {StringData} from "@github/actions-expressions/data/string";
|
||||
import {WorkflowContext} from "../context/workflow-context";
|
||||
import {Mode} from "./default";
|
||||
import {getDescription} from "./descriptions";
|
||||
|
||||
export function getSecretsContext(workflowContext: WorkflowContext, mode: Mode): DescriptionDictionary {
|
||||
const d = new DescriptionDictionary({
|
||||
key: "GITHUB_TOKEN",
|
||||
value: new data.StringData("***"),
|
||||
description: getDescription("secrets", "GITHUB_TOKEN")
|
||||
});
|
||||
|
||||
if (mode === Mode.Completion) {
|
||||
const eventsConfig = workflowContext?.template?.events;
|
||||
if (eventsConfig?.workflow_call?.secrets) {
|
||||
for (const [name, value] of Object.entries(eventsConfig.workflow_call.secrets)) {
|
||||
d.add(name, new StringData(""), value.description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const events = workflowContext?.template?.events;
|
||||
if (!events) {
|
||||
return d;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
Reference in New Issue
Block a user