why does this not work?
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
import {data, DescriptionDictionary} from "@actions/expressions";
|
import { data, DescriptionDictionary } from "@actions/expressions";
|
||||||
import {StringData} from "@actions/expressions/data/string";
|
import { StringData } from "@actions/expressions/data/string";
|
||||||
import {Mode} from "@actions/languageservice/context-providers/default";
|
import { Mode } from "@actions/languageservice/context-providers/default";
|
||||||
import {WorkflowContext} from "@actions/languageservice/context/workflow-context";
|
import { WorkflowContext } from "@actions/languageservice/context/workflow-context";
|
||||||
import {warn} from "@actions/languageservice/log";
|
import { warn } from "@actions/languageservice/log";
|
||||||
import {isMapping, isString} from "@actions/workflow-parser";
|
import { isMapping, isString } from "@actions/workflow-parser";
|
||||||
import {Octokit} from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
|
|
||||||
import {RepositoryContext} from "../initializationOptions";
|
import { RepositoryContext } from "../initializationOptions";
|
||||||
import {TTLCache} from "../utils/cache";
|
import { TTLCache } from "../utils/cache";
|
||||||
import {errorStatus} from "../utils/error";
|
import { errorStatus } from "../utils/error";
|
||||||
import {getRepoPermission} from "../utils/repo-permission";
|
import { getRepoPermission } from "../utils/repo-permission";
|
||||||
|
|
||||||
export async function getSecrets(
|
export async function getSecrets(
|
||||||
workflowContext: WorkflowContext,
|
workflowContext: WorkflowContext,
|
||||||
@@ -28,6 +28,8 @@ export async function getSecrets(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const eventsConfig = workflowContext?.template?.events;
|
const eventsConfig = workflowContext?.template?.events;
|
||||||
|
const dynamicEnv = workflowContext?.template?.env
|
||||||
|
|
||||||
if (eventsConfig?.workflow_call) {
|
if (eventsConfig?.workflow_call) {
|
||||||
// Unpredictable secrets may be passed in via a workflow_call trigger
|
// Unpredictable secrets may be passed in via a workflow_call trigger
|
||||||
secretsContext.complete = false;
|
secretsContext.complete = false;
|
||||||
@@ -38,6 +40,7 @@ export async function getSecrets(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let environmentName: string | undefined;
|
let environmentName: string | undefined;
|
||||||
|
|
||||||
if (workflowContext?.job?.environment) {
|
if (workflowContext?.job?.environment) {
|
||||||
if (isString(workflowContext.job.environment)) {
|
if (isString(workflowContext.job.environment)) {
|
||||||
environmentName = workflowContext.job.environment.value;
|
environmentName = workflowContext.job.environment.value;
|
||||||
@@ -53,6 +56,25 @@ export async function getSecrets(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let isDynamicEnv = false;
|
||||||
|
if (workflowContext.job?.environment && isMapping(workflowContext.job.environment)) {
|
||||||
|
for (const k of workflowContext.job.environment) {
|
||||||
|
// check if the value starts with ${{
|
||||||
|
if (isString(k.value) && k.value.value.startsWith("${{")) {
|
||||||
|
isDynamicEnv = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`isDynamicEnv: ${isDynamicEnv}`)
|
||||||
|
if (isDynamicEnv) {
|
||||||
|
secretsContext.complete = false;
|
||||||
|
if (mode === Mode.Validation) {
|
||||||
|
return secretsContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const secrets = await getRemoteSecrets(octokit, cache, repo, environmentName);
|
const secrets = await getRemoteSecrets(octokit, cache, repo, environmentName);
|
||||||
|
|
||||||
// Build combined map of secrets
|
// Build combined map of secrets
|
||||||
@@ -171,7 +193,7 @@ async function fetchOrganizationSecrets(octokit: Octokit, repo: RepositoryContex
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const secrets: {name: string}[] = await octokit.paginate("GET /repos/{owner}/{repo}/actions/organization-secrets", {
|
const secrets: { name: string }[] = await octokit.paginate("GET /repos/{owner}/{repo}/actions/organization-secrets", {
|
||||||
owner: repo.owner,
|
owner: repo.owner,
|
||||||
repo: repo.name,
|
repo: repo.name,
|
||||||
per_page: 100
|
per_page: 100
|
||||||
|
|||||||
Reference in New Issue
Block a user