fix(build): rename GITUH_PAT -> GH_PAT

This commit is contained in:
Pihkaal
2024-09-12 17:44:10 +02:00
parent 484cd937ab
commit c98306fecb
2 changed files with 10 additions and 9 deletions

View File

@@ -3,9 +3,10 @@ import { configDotenv } from "dotenv";
configDotenv();
// yeah ok might be overkill lol but I had more env variables before
const schema = z.object({
GITHUB_PAT: z.string().min(1),
GITHUB_USERNAME: z.string().min(1),
GH_PAT: z.string().min(1),
});
const result = schema.safeParse(process.env);

View File

@@ -31,13 +31,13 @@ type File = {
export const manifest = (): Plugin => ({
name: "generate-pages-plugin",
buildStart: async () => {
const octokit = new Octokit({ auth: env.GITHUB_PAT });
const octokit = new Octokit({ auth: env.GH_PAT });
let manifestRepo: RestEndpointMethodTypes["repos"]["get"]["response"]["data"];
try {
const { data } = await octokit.repos.get({
owner: env.GITHUB_USERNAME,
repo: env.GITHUB_USERNAME,
owner: "pihkaal",
repo: "pihkaal",
});
manifestRepo = data;
} catch {
@@ -56,12 +56,12 @@ export const manifest = (): Plugin => ({
if (storedUpdatedAt === manifestRepo.updated_at) return;
} catch {}
await mkdir("./node_modules/.cache");
await mkdir("./node_modules/.cache", { recursive: true });
await writeFile("./node_modules/.cache/assets", manifestRepo.updated_at);
const getRepoFileContent = async (repo: string, path: string) => {
const { data: file } = await octokit.repos.getContent({
owner: env.GITHUB_USERNAME,
owner: "pihkaal",
repo,
path,
});
@@ -72,13 +72,13 @@ export const manifest = (): Plugin => ({
};
const manifest = JSON.parse(
await getRepoFileContent(env.GITHUB_USERNAME, "manifest.json"),
await getRepoFileContent("pihkaal", "manifest.json"),
) as Manifest;
const projects: Array<Project> = [];
for (const project of manifest.projects) {
const { data: repo } = await octokit.repos.get({
owner: env.GITHUB_USERNAME,
owner: "pihkaal",
repo: project,
});
const content = await getRepoFileContent(project, "README.md");