All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m59s
- 镜像构建时会向项目目录内的version.json写入构建时间与commit-sha,并在镜像启动时输出日志 - 添加用于获取版本号的server api
17 lines
419 B
TypeScript
17 lines
419 B
TypeScript
import { existsSync, readFileSync } from 'fs';
|
|
import { execSync } from 'child_process';
|
|
|
|
export default defineEventHandler(() => {
|
|
const path = process.cwd() + '/version.json';
|
|
|
|
if (existsSync(path)) {
|
|
return JSON.parse(readFileSync(path, 'utf-8'));
|
|
}
|
|
|
|
return {
|
|
buildTime: new Date().toISOString(),
|
|
gitCommit: execSync('git rev-parse --short HEAD').toString().trim(),
|
|
generated: true,
|
|
};
|
|
});
|