Skip to content

Commit f8fc06d

Browse files
committed
back to Artur's way of passing commit hash, handle gitVersion in the astro config
1 parent 0d4466e commit f8fc06d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.github/workflows/preview.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ jobs:
3939
BRANCH_NAME=$(make safe_branch BRANCH=$GITHUB_BRANCH_NAME)
4040
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
4141
42-
- name: Export short commit hash
43-
run:
44-
echo "GITHUB_COMMIT_HASH=${GITHUB_COMMIT_HASH:0:7}" >> "$GITHUB_ENV"
45-
4642
- name: Build the website
4743
run: |
4844
make build MODE=preview

astro.config.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ import deleteUnusedImages from "astro-delete-unused-images";
1313
import preload from "astro-preload";
1414
import { execSync } from "node:child_process";
1515

16-
let gitVersion = "";
17-
try {
18-
gitVersion = execSync("git rev-parse --short HEAD 2>&1 > /dev/null");
19-
} catch (e) {}
16+
let gitVersion = String(import.meta.env.GIT_VERSION ?? "").slice(0, 7);
17+
18+
if (!gitVersion) {
19+
try {
20+
gitVersion = execSync("git rev-parse --short HEAD", {
21+
stdio: ["ignore", "pipe", "ignore"],
22+
})
23+
.toString()
24+
.trim();
25+
} catch {
26+
gitVersion = "unknown";
27+
}
28+
}
2029

2130
// https://astro.build/config
2231
export default defineConfig({

0 commit comments

Comments
 (0)