Always include GITHUB_TOKEN in the secrets

This commit is contained in:
Christopher Schleiden
2022-12-07 18:10:27 -08:00
parent aace05c8bb
commit 0b2c8c5e46
5 changed files with 21 additions and 23 deletions
@@ -18,13 +18,14 @@ export function contextProviders(
auth: sessionToken
});
const getContext = async (name: string) => {
const getContext = async (name: string, defaultContext: data.Dictionary | undefined) => {
switch (name) {
case "secrets":
const secrets = await getSecrets(octokit, cache, repo.owner, repo.name);
const secretContext = new data.Dictionary();
secrets.forEach(secret => secretContext.add(secret.value, secret));
return secretContext;
defaultContext = defaultContext || new data.Dictionary();
secrets.forEach(secret => defaultContext!.add(secret.value, new data.StringData("***")));
return defaultContext;
}
};
@@ -2,8 +2,15 @@ import {StringData} from "@github/actions-expressions/data/string";
import {Octokit} from "@octokit/rest";
import {TTLCache} from "../utils/cache";
export function getSecrets(octokit: Octokit, cache: TTLCache, owner: string, name: string): Promise<StringData[]> {
return cache.get(`${owner}/${name}/secrets`, undefined, () => fetchSecrets(octokit, owner, name));
export async function getSecrets(
octokit: Octokit,
cache: TTLCache,
owner: string,
name: string
): Promise<StringData[]> {
const repoSecrets = await cache.get(`${owner}/${name}/secrets`, undefined, () => fetchSecrets(octokit, owner, name));
return repoSecrets;
}
async function fetchSecrets(octokit: Octokit, owner: string, name: string): Promise<StringData[]> {