Fix #3232 Disclaimer: This code was mostly generated by GitHub Copilot agent using Sonnet-4, but tested and verified by me. --------- Co-authored-by: Marvin Hagemeister <marvin@deno.com>
21 lines
524 B
TypeScript
21 lines
524 B
TypeScript
import { encodeHex } from "@std/encoding/hex";
|
|
|
|
export const DENO_DEPLOYMENT_ID: string | undefined = Deno.env.get(
|
|
"DENO_DEPLOYMENT_ID",
|
|
);
|
|
const deploymentId = DENO_DEPLOYMENT_ID ||
|
|
// For CI
|
|
Deno.env.get("GITHUB_SHA") ||
|
|
Deno.env.get("CI_COMMIT_SHA") ||
|
|
crypto.randomUUID();
|
|
const buildIdHash = await crypto.subtle.digest(
|
|
"SHA-1",
|
|
new TextEncoder().encode(deploymentId),
|
|
);
|
|
|
|
export let BUILD_ID: string = encodeHex(buildIdHash);
|
|
|
|
export function setBuildId(buildId: string): void {
|
|
BUILD_ID = buildId;
|
|
}
|