Files
ljwx-harbor/gitea/enable-gitea-actions.md
gaoandClaude 8f47f4e9ea feat: 完善 DevOps 工具链配置和优化 Harbor 服务
- 更新 Gitea runner 配置,支持优化的 CI/CD 环境
- 完善 Harbor HTTPS 配置和远程访问支持
- 优化 Harbor 日志配置,改用 json-file 驱动
- 添加 Docker 构建加速和代理缓存脚本
- 新增完整的文档和使用指南
- 添加 AI 开发工具集成配置

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 06:39:53 +08:00

4.5 KiB
Raw Permalink Blame History

🔧 启用 Gitea Actions 指南

问题: 当前 Gitea 实例中 Actions 功能未启用 ("has_actions":false) 解决: 需要在 Gitea 管理后台启用 Actions 功能


🎯 问题诊断

通过 API 检查发现:

{
  "has_actions": false,
  "open_pr_counter": 1  // 你的 PR #1 已经创建
}

虽然 PR 已经创建,但 Actions 功能未启用,所以工作流不会触发。


🚀 解决方案

第一步:以管理员身份登录 Gitea

  1. 访问: http://localhost:33000
  2. 使用管理员账户登录
  3. 进入管理后台

第二步:启用 Actions 功能

  1. 进入管理设置:

    点击右上角头像 → Site Administration
    
  2. 找到 Actions 设置:

    左侧菜单 → Actions
    
  3. 启用 Actions:

    ✅ 勾选 "Enable Actions"
    
  4. 配置网络设置 (如果需要):

    如果需要从 GitHub 拉取 actions,配置网络出口或使用镜像
    
  5. 保存设置:

    点击 "Save Settings" 或 "保存设置"
    

第三步:验证 Actions 已启用

启用后,你应该能看到:

  1. 仓库页面出现 Actions 标签:

    仓库页面 → 应该有 "Actions" 菜单项
    
  2. PR 页面显示状态检查:

    PR #1 页面 → 应该显示 "Checks" 或 "状态检查"
    
  3. Runner 显示活跃状态:

    仓库设置 → Actions → Runners → 应该显示 "Active"
    

🔧 验证步骤

1. 检查仓库 Actions 状态

启用后,重新检查 API:

curl -s http://localhost:33000/api/v1/repos/gao/ai-stock | jq '.has_actions'
# 应该返回: true

2. 手动触发工作流

如果启用后工作流仍未触发,可以尝试:

# 1. 推送一个新提交到 PR 分支
git checkout test-workflow-trigger
echo "# 更新测试内容" >> TEST_WORKFLOW.md
git add TEST_WORKFLOW.md
git commit -m "test: 触发 Actions 工作流"
git push origin test-workflow-trigger

# 2. 或者在 PR 中添加新评论
# 在 PR 页面添加评论,有时可以触发重新检查

3. 检查 Runner 日志

cd /Users/brunogao/work/codes/tools/macos/gitea/runners
tail -f runner.log
# 应该能看到新的任务进入

🎯 预期结果

启用 Actions 后,你应该看到:

✅ Gitea 界面变化

  • 仓库页面出现 "Actions" 菜单
  • PR 页面显示状态检查区域
  • 仓库设置中出现 Actions 选项

✅ 工作流自动执行

  • PR 创建时自动触发工作流
  • Runner 接收并执行任务
  • 检查结果显示在 PR 页面

✅ Runner 任务日志

# Runner 日志应该显示类似内容:
time="2025-10-28T15:xx:xx+08:00" level=info msg="Received job"
time="2025-10-28T15:xx:xx+08:00" level=info msg="Starting job: frontend-quality"
time="2025-10-28T15:xx:xx+08:00" level=info msg="Job completed"

🔍 故障排除

如果启用后仍不工作

  1. 重启 Gitea 服务:

    cd /Users/brunogao/work/codes/tools/macos/gitea
    docker-compose restart
    
  2. 重新注册 Runner:

    cd /Users/brunogao/work/codes/tools/macos/gitea/runners
    ./manage-runner.sh stop
    echo -e "http://localhost:33000\ne9udfPmR6PsKbTXNRY61fMiGpmVBXv1PRKhbTfPD\nmacos-local-runner\nmacos,amd64,docker,local" | /Users/brunogao/bin/act_runner register
    ./manage-runner.sh start
    
  3. 检查工作流文件:

    # 确保工作流文件语法正确
    cat /Users/brunogao/work/codes/stock/ai_stock/.gitea/workflows/quality-gate.yml
    
  4. 创建新的 PR:

    # 创建一个新的分支来测试
    git checkout -b test-actions-again
    echo "Actions 测试" > actions-test.md
    git add actions-test.md
    git commit -m "test: 再次测试 Actions"
    git push origin test-actions-again
    

📞 获取帮助

🛠️ 管理工具

# Runner 管理
cd /Users/brunogao/work/codes/tools/macos/gitea/runners
./manage-runner.sh status
./manage-runner.sh logs
./manage-runner.sh health

📚 相关文档


🎉 总结

当前状态:

  • ✅ Runner 已部署并运行
  • ✅ 工作流文件已配置
  • ✅ PR #1 已创建
  • ❌ Gitea Actions 功能未启用

下一步:

  1. 以管理员身份登录 Gitea
  2. 进入 Site Administration → Actions
  3. 启用 Actions 功能
  4. 验证工作流自动触发

🚀 启用 Actions 后,PR #1 应该会自动触发完整的质量门禁检查!