deploy_gitrepo

stars

A very simple server for creating mirroring sites of github with deno deploy.

How to use?

First Step

Place serve.ts in your repository with the following:

// serve.ts
import { serve } from "https://deploy-gitrepo.deno.dev/v0.0.3/serve.ts";

serve({
  owner: "your_account_name",
  repo: "your_repository_name",
});

Second Step

Sign up for deno deploy, create a new project, and register serve.ts in "git integration".

Feature

Supports version control of git tags.

Specify the converters option to convert the content.

// serve.ts
import { serve } from "https://deploy-gitrepo.deno.dev/v0.0.3/serve.ts";
import { mdToHTML } from "https://deploy-gitrepo.deno.dev/v0.0.3/md_to_html.ts";

const converters = [{
  // When `match` returns true, the` convert` function is called.
  match: (request: Request) => new URL(request.url).pathname.endsWith(".md"),
  convert: mdToHTML,
}];

serve({
  owner: "your_account_name",
  repo: "your_repository_name",
  converters,
});
// serve.ts
import { serve } from "https://deploy-gitrepo.deno.dev/v0.0.3/serve.ts";
import { tsToJs } from "https://deploy-gitrepo.deno.dev/v0.0.3/ts_to_js.ts";

const converters = [{
  // Only the first matching converter will be used.
  match: (request: Request) =>
    new URL(request.url).pathname.endsWith(".ts") &&
    !request.headers.get("user-agent")?.includes("Deno"),
  convert: tsToJs,
}, {
  match: (request: Request) => {
    const { pathname } = new URL(request.url);
    return pathname.endsWith(".ts") || pathname.endsWith(".js");
  },
  convert: ({ content }: { content: string }) => ({
    content,
    headers: { "Access-Control-Allow-Origin": "*" },
  }),
}];

serve({
  owner: "your_account_name",
  repo: "your_repository_name",
  converters,
});

⚠️ Due to the CPU time limit of the deployment, it can be difficult to include markdown conversion and TypeScript conversion at the same time. Both use wasm. This may be resolved at https://github.com/denoland/deploy_feedback/issues/95.

Supports github personal access tokens.

// serve.ts
import { serve } from "https://deploy-gitrepo.deno.dev/v0.0.3/serve.ts";

serve({
  owner: "your_account_name",
  repo: "your_repository_name",
  tokenKey: "key_of_token", // The key of the environment variable that stores the personal access token of github. (in short, `Deno.env.get("key_of_token")==="<your_token>"`)
});

Link

github