Skip to content

Commit cc188e9

Browse files
feat: read GitLab env var too
1 parent 7131216 commit cc188e9

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

packages/build-id/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const DENO_DEPLOYMENT_ID: string | undefined = Deno.env.get(
66
const deploymentId = DENO_DEPLOYMENT_ID ||
77
// For CI
88
Deno.env.get("GITHUB_SHA") ||
9+
Deno.env.get("CI_COMMIT_SHA") ||
910
crypto.randomUUID();
1011
const buildIdHash = await crypto.subtle.digest(
1112
"SHA-1",

packages/plugin-vite/src/plugins/build_id.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,22 @@ export function setBuildId(id) {
3939
}
4040

4141
export async function getBuildId(dev: boolean): Promise<string> {
42-
// Check for GIT_REVISION environment variable first
43-
const gitRevision = Deno.env.get("GIT_REVISION");
42+
const gitRevision = Deno.env.get("DENO_DEPLOYMENT_ID") ??
43+
Deno.env.get("GITHUB_SHA") ?? Deno.env.get("CI_COMMIT_SHA");
4444
if (gitRevision !== undefined) {
4545
return gitRevision;
4646
}
4747

4848
if (!dev) {
49-
const bin = Deno.build.os === "windows" ? "git.exe" : "git";
50-
const res = await new Deno.Command(bin, { args: ["rev-parse", "HEAD"] })
51-
.output();
52-
53-
return new TextDecoder().decode(res.stdout);
49+
try {
50+
const bin = Deno.build.os === "windows" ? "git.exe" : "git";
51+
const res = await new Deno.Command(bin, { args: ["rev-parse", "HEAD"] })
52+
.output();
53+
54+
return new TextDecoder().decode(res.stdout);
55+
} catch {
56+
// ignore
57+
}
5458
}
5559

5660
const arr = new Uint32Array(1);

0 commit comments

Comments
 (0)