feat: add Git user identity configuration for CI environments

- Implemented a check for Git user identity in the `pushManifestToRemoteRepo` function to handle cases where the identity is not configured in CI environments.
- Added logic to set a default CI user identity if none is found, ensuring smooth operation during automated deployments.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-06-28 20:43:50 +08:00
parent 9e0f21591a
commit 2c36c52f4d
2 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
<!-- Generated by SpecStory -->
# Untitled (2025-06-28 20:42:26)
_**User**_
这里需要增加判断 CI 中跑可能没有这个信息
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
---
_**Assistant**_
我看到你遇到了在 CI 环境中 Git 缺少用户身份配置的问题。我需要在 `pushManifestToRemoteRepo` 函数中添加 Git 用户身份的检查和配置。
---
```diff
logger.main.info('📤 开始推送更新到远程仓库...')
+
+ // 配置 Git 用户身份(特别是在 CI 环境中)
+ try {
+ // 检查是否已配置用户身份
+ await $({
+ cwd: assetsGitDir,
+ stdio: 'pipe',
+ })`git config user.name`
+ } catch {
+ // 如果没有配置,则设置默认的 CI 用户身份
+ logger.main.info('🔧 配置 Git 用户身份CI 环境)...')
+ await $({
+ cwd: assetsGitDir,
+ stdio: 'pipe',
+ })`git config user.email "ci@photo-gallery.local"`
+ await $({
+ cwd: assetsGitDir,
+ stdio: 'pipe',
+ })`git config user.name "Photo Gallery CI"`
+ }
// 检查是否有变更
```
---
现在我已经在 `pushManifestToRemoteRepo`
---