update
This commit is contained in:
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@@ -23,6 +23,13 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set build env
|
||||||
|
run: |
|
||||||
|
echo "BUILD_SHA=${{ github.sha }}" >> $GITHUB_ENV
|
||||||
|
echo "BUILD_SHORT=${{ steps.commit-hash.outputs.short }}" >> $GITHUB_ENV
|
||||||
|
echo "BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> $GITHUB_ENV
|
||||||
|
echo "BUILD_MESSAGE=${{ github.event.head_commit.message || '' }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install Node.js
|
- name: Install Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,40 +1,16 @@
|
|||||||
import siteConfig from "./app/config";
|
import siteConfig from "./app/config";
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
import { execSync } from "child_process";
|
|
||||||
|
|
||||||
// Compute git build info at build time. If git isn't available (e.g. in
|
|
||||||
// certain CI environments), fields will be empty strings.
|
|
||||||
const runGit = (cmd: string) => {
|
|
||||||
try {
|
|
||||||
return execSync(cmd, { encoding: "utf8" }).trim();
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const gitSha = runGit("git rev-parse HEAD");
|
|
||||||
const gitShort = runGit("git rev-parse --short HEAD");
|
|
||||||
const gitMessage = runGit("git log -1 --pretty=%B");
|
|
||||||
const gitDate = runGit("git show -s --format=%ci HEAD");
|
|
||||||
|
|
||||||
// Prefer build info from environment variables (set by GitHub Actions
|
|
||||||
// or custom CI). Supported vars (in priority order):
|
|
||||||
// - BUILD_SHA, GITHUB_SHA
|
|
||||||
// - BUILD_SHORT, (derived from SHA if missing)
|
|
||||||
// - BUILD_MESSAGE
|
|
||||||
// - BUILD_DATE
|
|
||||||
// Falls back to git-derived values when env vars are not present.
|
|
||||||
const envSha = process.env.BUILD_SHA || process.env.GITHUB_SHA || "";
|
const envSha = process.env.BUILD_SHA || process.env.GITHUB_SHA || "";
|
||||||
const envShort = process.env.BUILD_SHORT || (envSha ? envSha.slice(0, 7) : "") || gitShort || "";
|
const envShort = process.env.BUILD_SHORT || (envSha ? envSha.slice(0, 7) : "") || "";
|
||||||
const envMessage = process.env.BUILD_MESSAGE || "";
|
const envMessage = process.env.BUILD_MESSAGE || "";
|
||||||
const envDate = process.env.BUILD_DATE || "";
|
const envDate = process.env.BUILD_DATE || "";
|
||||||
|
|
||||||
const gitBuild = {
|
const gitBuild = {
|
||||||
sha: envSha || gitSha,
|
sha: envSha,
|
||||||
short: envShort || gitShort,
|
short: envShort,
|
||||||
message: envMessage || gitMessage,
|
message: envMessage,
|
||||||
date: envDate || gitDate,
|
date: envDate,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
|||||||
Reference in New Issue
Block a user