import * as wmill from "npm:windmill-client@1";
import { Octokit } from "npm:@octokit/rest@20.0.2";
export async function main(
font_file: wmill.Base64,
font_name: string,
font_type: string,
) {
const octokit = new Octokit({
auth: (await wmill.getVariable("f/COMPANY/GITHUB_TOKEN")),
});
const acceptedFileTypes = ["otf", "ttf"];
if (acceptedFileTypes.includes(font_type) && font_name && font_name !== "") {
const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: 'PATH',
message: 'MESSAGE',
content: font_file,
});
const res = await fetch(
"ENDPOINT TO NOTIFY FILE IS UPLOAD, NOT RELEVANT FOR THIS ISSUE",
);
const responseText = res.text();
return responseText || 500;
} else {
return "error: unsupported file extension, must be otf or ttf.";
}
}
import * as wmill from "npm:windmill-client@1";
import { Octokit } from "npm:@octokit/rest@20.0.2";
export async function main(
font_file: wmill.Base64,
font_name: string,
font_type: string,
) {
const octokit = new Octokit({
auth: (await wmill.getVariable("f/COMPANY/GITHUB_TOKEN")),
});
const acceptedFileTypes = ["otf", "ttf"];
if (acceptedFileTypes.includes(font_type) && font_name && font_name !== "") {
const result = await octokit.repos.createOrUpdateFileContents({
owner: "OWNER",
repo: "REPO",
path: 'PATH',
message: 'MESSAGE',
content: font_file,
});
const res = await fetch(
"ENDPOINT TO NOTIFY FILE IS UPLOAD, NOT RELEVANT FOR THIS ISSUE",
);
const responseText = res.text();
return responseText || 500;
} else {
return "error: unsupported file extension, must be otf or ttf.";
}
}