fix(build): rename GITUH_PAT -> GH_PAT
This commit is contained in:
@@ -3,9 +3,10 @@ import { configDotenv } from "dotenv";
|
|||||||
|
|
||||||
configDotenv();
|
configDotenv();
|
||||||
|
|
||||||
|
// yeah ok might be overkill lol but I had more env variables before
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
GITHUB_PAT: z.string().min(1),
|
GH_PAT: z.string().min(1),
|
||||||
GITHUB_USERNAME: z.string().min(1),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = schema.safeParse(process.env);
|
const result = schema.safeParse(process.env);
|
||||||
|
|||||||
@@ -31,13 +31,13 @@ type File = {
|
|||||||
export const manifest = (): Plugin => ({
|
export const manifest = (): Plugin => ({
|
||||||
name: "generate-pages-plugin",
|
name: "generate-pages-plugin",
|
||||||
buildStart: async () => {
|
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"];
|
let manifestRepo: RestEndpointMethodTypes["repos"]["get"]["response"]["data"];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await octokit.repos.get({
|
const { data } = await octokit.repos.get({
|
||||||
owner: env.GITHUB_USERNAME,
|
owner: "pihkaal",
|
||||||
repo: env.GITHUB_USERNAME,
|
repo: "pihkaal",
|
||||||
});
|
});
|
||||||
manifestRepo = data;
|
manifestRepo = data;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -56,12 +56,12 @@ export const manifest = (): Plugin => ({
|
|||||||
if (storedUpdatedAt === manifestRepo.updated_at) return;
|
if (storedUpdatedAt === manifestRepo.updated_at) return;
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
await mkdir("./node_modules/.cache");
|
await mkdir("./node_modules/.cache", { recursive: true });
|
||||||
await writeFile("./node_modules/.cache/assets", manifestRepo.updated_at);
|
await writeFile("./node_modules/.cache/assets", manifestRepo.updated_at);
|
||||||
|
|
||||||
const getRepoFileContent = async (repo: string, path: string) => {
|
const getRepoFileContent = async (repo: string, path: string) => {
|
||||||
const { data: file } = await octokit.repos.getContent({
|
const { data: file } = await octokit.repos.getContent({
|
||||||
owner: env.GITHUB_USERNAME,
|
owner: "pihkaal",
|
||||||
repo,
|
repo,
|
||||||
path,
|
path,
|
||||||
});
|
});
|
||||||
@@ -72,13 +72,13 @@ export const manifest = (): Plugin => ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const manifest = JSON.parse(
|
const manifest = JSON.parse(
|
||||||
await getRepoFileContent(env.GITHUB_USERNAME, "manifest.json"),
|
await getRepoFileContent("pihkaal", "manifest.json"),
|
||||||
) as Manifest;
|
) as Manifest;
|
||||||
|
|
||||||
const projects: Array<Project> = [];
|
const projects: Array<Project> = [];
|
||||||
for (const project of manifest.projects) {
|
for (const project of manifest.projects) {
|
||||||
const { data: repo } = await octokit.repos.get({
|
const { data: repo } = await octokit.repos.get({
|
||||||
owner: env.GITHUB_USERNAME,
|
owner: "pihkaal",
|
||||||
repo: project,
|
repo: project,
|
||||||
});
|
});
|
||||||
const content = await getRepoFileContent(project, "README.md");
|
const content = await getRepoFileContent(project, "README.md");
|
||||||
|
|||||||
Reference in New Issue
Block a user