Merge pull request #176 from github/elbrenn/called-secret-complete
Convert secrets, complete secrets in called workflow
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {DescriptionDictionary} from "@github/actions-expressions";
|
||||
import {ContextProviderConfig} from "@github/actions-languageservice";
|
||||
import {Mode} from "@github/actions-languageservice/context-providers/default";
|
||||
import {WorkflowContext} from "@github/actions-languageservice/context/workflow-context";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
import {getSecrets} from "./context-providers/secrets";
|
||||
@@ -20,11 +21,12 @@ export function contextProviders(
|
||||
const getContext = async (
|
||||
name: string,
|
||||
defaultContext: DescriptionDictionary | undefined,
|
||||
workflowContext: WorkflowContext
|
||||
workflowContext: WorkflowContext,
|
||||
mode: Mode
|
||||
) => {
|
||||
switch (name) {
|
||||
case "secrets":
|
||||
return await getSecrets(workflowContext, client, cache, repo, defaultContext);
|
||||
return await getSecrets(workflowContext, client, cache, repo, defaultContext, mode);
|
||||
case "vars":
|
||||
return await getVariables(workflowContext, client, cache, repo, defaultContext);
|
||||
case "steps":
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {data, DescriptionDictionary} from "@github/actions-expressions";
|
||||
import {StringData} from "@github/actions-expressions/data/string";
|
||||
import {Mode} from "@github/actions-languageservice/context-providers/default";
|
||||
import {WorkflowContext} from "@github/actions-languageservice/context/workflow-context";
|
||||
import {isMapping, isString} from "@github/actions-workflow-parser";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
@@ -12,7 +13,8 @@ export async function getSecrets(
|
||||
octokit: Octokit,
|
||||
cache: TTLCache,
|
||||
repo: RepositoryContext,
|
||||
defaultContext: DescriptionDictionary | undefined
|
||||
defaultContext: DescriptionDictionary | undefined,
|
||||
mode: Mode
|
||||
): Promise<DescriptionDictionary> {
|
||||
const permission = await getRepoPermission(octokit, cache, repo);
|
||||
if (permission === "none") {
|
||||
@@ -38,6 +40,15 @@ export async function getSecrets(
|
||||
}
|
||||
|
||||
const secretsContext = defaultContext || new DescriptionDictionary();
|
||||
|
||||
// Exit early if workflow_call is the only trigger
|
||||
if (mode === Mode.Completion) {
|
||||
const eventsConfig = workflowContext?.template?.events;
|
||||
if (eventsConfig?.workflow_call && Object.keys(eventsConfig).length == 1) {
|
||||
return secretsContext;
|
||||
}
|
||||
}
|
||||
|
||||
const secrets = await getRemoteSecrets(octokit, cache, repo, environmentName);
|
||||
|
||||
// Build combined map of secrets
|
||||
|
||||
Reference in New Issue
Block a user