mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
feat: 将admin-spa构建迁移到GitHub Actions workflow
🔄 主要改进: - 在自动发布流程中添加admin-spa前端构建步骤 - 仅在web/admin-spa目录有改动时才触发构建 - 构建后的dist目录会自动包含在版本发布中 - 移除手动提交的dist目录,避免安全风险 🐛 修复: - 修复登录后用户名显示为默认"Admin"的问题 - 现在会正确从服务器获取并显示实际用户名 🔒 安全优化: - 防止恶意代码通过dist目录注入 - 所有前端代码都会在CI环境中重新构建 现在开发者无需手动构建前端,workflow会自动处理 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
4
.github/cliff.toml
vendored
4
.github/cliff.toml
vendored
@@ -18,7 +18,7 @@ body = """
|
||||
{% for group, commits in commits | group_by(attribute="group") %}
|
||||
### {{ group | upper_first }}
|
||||
{% for commit in commits %}
|
||||
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/orhun/git-cliff/commit/{{ commit.id }}))
|
||||
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }} ([{{ commit.id | truncate(length=7, end="") }}](https://github.com/Wei-Shaw/claude-relay-service/commit/{{ commit.id }}))
|
||||
{%- endfor %}
|
||||
{% endfor %}\n
|
||||
"""
|
||||
@@ -37,7 +37,7 @@ filter_unconventional = true
|
||||
split_commits = false
|
||||
# regex for preprocessing the commit messages
|
||||
commit_preprocessors = [
|
||||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))" },
|
||||
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/Wei-Shaw/claude-relay-service/issues/${2}))" },
|
||||
]
|
||||
# regex for parsing and grouping commits
|
||||
commit_parsers = [
|
||||
|
||||
61
.github/workflows/auto-release-pipeline.yml
vendored
61
.github/workflows/auto-release-pipeline.yml
vendored
@@ -103,6 +103,53 @@ jobs:
|
||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
echo "new_tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Check if frontend build is needed
|
||||
id: check_frontend
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
# 检查 web/admin-spa 目录是否有变更
|
||||
FRONTEND_CHANGES=false
|
||||
CHANGED_FILES=$(git diff --name-only HEAD~1..HEAD 2>/dev/null || git diff --name-only $(git rev-list --max-parents=0 HEAD)..HEAD)
|
||||
|
||||
while IFS= read -r file; do
|
||||
if [[ "$file" =~ ^web/admin-spa/ ]] &&
|
||||
[[ ! "$file" =~ ^web/admin-spa/dist/ ]] &&
|
||||
[[ ! "$file" =~ \.(md|txt)$ ]] &&
|
||||
[[ "$file" != "web/admin-spa/.gitignore" ]]; then
|
||||
echo "Found frontend change in: $file"
|
||||
FRONTEND_CHANGES=true
|
||||
break
|
||||
fi
|
||||
done <<< "$CHANGED_FILES"
|
||||
|
||||
echo "needs_build=$FRONTEND_CHANGES" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup Node.js
|
||||
if: steps.check.outputs.needs_bump == 'true' && steps.check_frontend.outputs.needs_build == 'true'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/admin-spa/package-lock.json
|
||||
|
||||
- name: Build admin-spa
|
||||
if: steps.check.outputs.needs_bump == 'true' && steps.check_frontend.outputs.needs_build == 'true'
|
||||
run: |
|
||||
echo "Building admin-spa frontend..."
|
||||
cd web/admin-spa
|
||||
npm ci
|
||||
npm run build
|
||||
cd ../..
|
||||
|
||||
# 确认 dist 目录已创建
|
||||
if [ -d "web/admin-spa/dist" ]; then
|
||||
echo "✅ Frontend build successful"
|
||||
ls -la web/admin-spa/dist/
|
||||
else
|
||||
echo "❌ Frontend build failed - dist directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Update VERSION file
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
run: |
|
||||
@@ -112,9 +159,19 @@ jobs:
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
# 提交VERSION文件 - 添加 [skip ci] 以避免再次触发
|
||||
# 检查是否需要添加 dist 目录
|
||||
if [ "${{ steps.check_frontend.outputs.needs_build }}" = "true" ] && [ -d "web/admin-spa/dist" ]; then
|
||||
git add -f web/admin-spa/dist/
|
||||
echo "Added frontend dist directory to commit"
|
||||
fi
|
||||
|
||||
# 提交VERSION文件和可能的dist目录 - 添加 [skip ci] 以避免再次触发
|
||||
git add VERSION
|
||||
git commit -m "chore: sync VERSION file with release ${{ steps.next_version.outputs.new_tag }} [skip ci]"
|
||||
if [ "${{ steps.check_frontend.outputs.needs_build }}" = "true" ]; then
|
||||
git commit -m "chore: sync VERSION file with release ${{ steps.next_version.outputs.new_tag }} and rebuild frontend [skip ci]"
|
||||
else
|
||||
git commit -m "chore: sync VERSION file with release ${{ steps.next_version.outputs.new_tag }} [skip ci]"
|
||||
fi
|
||||
|
||||
- name: Install git-cliff
|
||||
if: steps.check.outputs.needs_bump == 'true'
|
||||
|
||||
Reference in New Issue
Block a user