Get custom values for environment

This commit is contained in:
Beth Brennan
2022-11-16 15:22:19 -05:00
committed by Beth Brennan
parent 7a6f26efdb
commit b0fda7d65c
2 changed files with 37 additions and 5 deletions
@@ -0,0 +1,24 @@
import { Value } from "@github/actions-languageservice/value-providers/config";
import { Octokit } from "@octokit/rest";
export async function getEnvironments(
client: Octokit,
owner: string,
name: string
): Promise<Value[]> {
let environments: string[] = [];
try {
const response = await client.repos.getAllEnvironments({
owner,
repo: name,
});
if (response.data.environments) {
environments = response.data.environments.map((env) => env.name);
}
} catch (e) {
console.log(e);
}
return Array.from(environments).map((e) => ({ label: e }));
}