WindmillWWindmill
Powered by
MikeM
Windmill•3y ago•
41 replies
Mike

Trouble committing file to GitHub but only in bun runtime

I'm trying to create a script to commit font files into my github repository. This is code that is migrated over from airplane.dev. Initially i created the code using the Deno runtime, this works but I want to use fontkit, which does not support the "import ... from ..." imports.

So the following code WORKS:

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.";
  }
}
WindmillJoin
3,362Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Recent Announcements
henri-c

Weekly kenote to tell you about our latest updates https://discord.com/channels/930051556043276338/1278977038430240813 https://youtube.com/live/2dGd9TdT8xs?feature=share

henri-c · 4d ago

Pyra

### HTTP tracing (EE) Capture HTTP requests made by job scripts as observability spans Features: - View HTTP request traces (method, URL, status, timing) in the job details UI - Auto-instrumentation for Native TypeScript, MITM proxy for other languages - Integrates with external OpenTelemetry collectors changelog: https://www.windmill.dev/changelog/http-tracing docs: https://www.windmill.dev/docs/advanced/instance_settings#http-tracing Additionally jobs memory metrics are now fully OSS!

Pyra · 2w ago

henri-c

First keynote of the year here https://discord.com/channels/930051556043276338/1278977038430240813 🙂

henri-c · 4w ago

Similar Threads

How to debug ExecutionErr(only Bun)?
EricEEric / help
2y ago
Telling Windmill to use `deno` runtime not `bun`
jakeoidJjakeoid / help
2y ago
Runtime arguments
pixeleetPpixeleet / help
2y ago
Invalid requirements, expectd to find //bun.lockb split pattern in reqs
cali (brazil)Ccali (brazil) / help
3y ago