Skip to content

Conversation

@ThirteenLLB
Copy link
Contributor

@ThirteenLLB ThirteenLLB commented Jan 30, 2026

Summary

  • 使用 jq 构建 JSON payload,自动处理换���符转义
  • 修复飞书卡片中 \n 显示为字面文本而非换行的问题
  • 简化代码,合并两个 step 为一个

Test plan

  • 运行 centralized-release 工作流
  • 验证飞书卡片中仓库列表正确换行显示

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • 修复 Feishu 卡片中新行处理,确保通知内容在消息中正确显示(改为构建 JSON 有效载荷)。
  • Chores

    • 将 Feishu 通知简化为单一调用,合并步骤并改进干跑与发布日期显示逻辑。
    • 优化仓库列表解析与展示格式,提升发布通知的可靠性与可读性。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

将 centralized-release 工作流中 Feishu 通知从多步骤、基于输出的构建改为单步骤在 runner 端用环境变量与运行时变量生成结构化 JSON(通过 jq),并用单次 curl 提交到 Feishu webhook;同时调整仓库列表解析与日期/干跑标识处理。

Changes

Cohort / File(s) Summary
工作流配置
.github/workflows/centralized-release.yml
合并并重构 Feishu 通知步骤:改用环境输入(WEBHOOK_URL、ACTOR、RUN_URL)、运行时变量(STATUS_EMOJI/STATUS_TEXT/CARD_COLOR)、用 REPO_LINES 替代原多行 Markdown,支持 :changelog_path 后缀和行内版本解析;用 jq 构建 JSON payload 并通过单次 curl 发送。
变更记录
CHANGELOG.md
新增 Fixed 子节:修复 Feishu 卡片换行问题,说明使用 jq 正确构建 JSON 以避免换行/转义错误。

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GH as "GitHub Actions Runner"
    participant Script as "notify Feishu shell script (jq)"
    participant Feishu as "Feishu Webhook API"

    GH->>Script: 读取环境输入 (WEBHOOK_URL, ACTOR, RUN_URL, RELEASE_DATE, REPO_LINES...)
    Script->>Script: 解析 REPO_LINES,提取 repo/version/changelog_path,计算 DISPLAY_DATE、DRY_RUN_TAG
    Script->>Script: 使用 jq 组装结构化 JSON payload (title, color, info, repos)
    Script->>Feishu: POST JSON payload -> WEBHOOK_URL (curl)
    Feishu-->>Script: 返回响应 (success/failure)
    Script-->>GH: 根据响应设置退出状态
Loading

Estimated code review effort

🎯 3 (中等复杂度) | ⏱️ ~20 分钟

Possibly related PRs

Suggested reviewers

  • chenjunnn
  • mookechee

概览

此PR重构了 Feishu 通知流程,将其从多步骤、输出驱动的方式改为单步骤服务器端 JSON 负载构造。通过引入环境变量和运行时状态变量,并采用 jq 动态生成通知 payload,简化了通知逻辑。

变更清单

分组 / 文件 变更摘要
工作流配置优化
.github/workflows/centralized-release.yml
重构 Notify Feishu 作业:将"构建通知内容"和"发送通知"的多步骤流程合并为单步骤;替换硬编码的 payload 为通过 jq 动态构造的 JSON 结构;引入 WEBHOOK_URL、ACTOR、RUN_URL 等环境变量;使用 STATUS_EMOJI、STATUS_TEXT、CARD_COLOR 等运行时变量替代 GITHUB_OUTPUT 写入;优化仓库列表处理为简单的 REPO_LINES 字符串累积,支持版本解析与 changelog_path 后缀。
变更记录
CHANGELOG.md
新增 Fixed 小节:修复 Feishu 卡片换行问题,记录使用 jq 构建 JSON 以正确处理换行与转义。

估算代码审查工作量

🎯 3 (中等复杂度) | ⏱️ ~20 分钟

可能相关的 PR

建议审阅人

  • chenjunnn
  • mookechee

兔子之歌

🐰 一步合并真轻快,
jq 搭桥把 JSON 摆;
仓库行列都整理,
通知直达不再歪;
小兔鼓掌庆一回 🎉

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题完全符合Conventional Commits格式,具体描述了主要变更(使用jq处理Feishu通知中的换行符),准确反映了pull request的核心目的。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Changelog ✅ Passed PR引入了用户facing的修复,修复了Feishu通知中的换行符处理问题,CHANGELOG.md已适当更新。
Pr Description ✅ Passed PR描述包含两个具体测试项,分支名称以'chore/'开头,工作项引用要求被豁免。
Branch Name ✅ Passed 源分支名称 chore/feishu-notification 完全符合规范的 Chore 分支命名模式 chore/<description>,清晰表示了 Feishu 通知功能的维护性工作。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/feishu-notification

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 30, 2026
@ThirteenLLB ThirteenLLB dismissed stale reviews from coderabbitai[bot] and christopheralex-cc January 30, 2026 14:34

The merge-base changed after approval.

@ThirteenLLB ThirteenLLB force-pushed the chore/feishu-notification branch from 0ec4daa to c4811d7 Compare January 30, 2026 14:34
@ThirteenLLB ThirteenLLB requested review from MyFirstGit-01 and removed request for MyFirstGit-01 January 30, 2026 14:38
Replace manual string escaping with jq for JSON construction.
This fixes the issue where \n was displayed as literal text instead
of being parsed as newlines in the Feishu card.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ThirteenLLB ThirteenLLB force-pushed the chore/feishu-notification branch from c4811d7 to b87d5bf Compare January 30, 2026 14:39
@ThirteenLLB ThirteenLLB merged commit b9cb52c into main Jan 30, 2026
1 check was pending
@ThirteenLLB ThirteenLLB deleted the chore/feishu-notification branch January 30, 2026 14:41
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/centralized-release.yml:
- Around line 264-266: The curl invocation that posts to $WEBHOOK_URL with -d
"$JSON_PAYLOAD" should treat HTTP 4xx/5xx as failures; update the curl command
(the existing curl -X POST "$WEBHOOK_URL" -H "Content-Type: application/json" -d
"$JSON_PAYLOAD") to include --fail (and optionally --show-error) and ensure the
step fails on a non‑zero exit (e.g., let the CI shell propagate curl's exit code
or add an explicit check) so the workflow errors when the notification request
fails.

Comment on lines +264 to +266
curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check curl version and --fail-with-body support
echo "=== Curl version ==="
curl --version | head -1

echo ""
echo "=== Checking for --fail-with-body flag ==="
curl --help | grep -i "fail-with-body" || echo "Flag not found"

echo ""
echo "=== Checking for --fail flag ==="
curl --help | grep -i "^[[:space:]]*--fail" | head -5

Repository: wuji-technology/.github

Length of output: 383


🏁 Script executed:

# Read the workflow file to understand context
cat -n .github/workflows/centralized-release.yml | sed -n '260,270p'

Repository: wuji-technology/.github

Length of output: 287


🏁 Script executed:

# Check broader context around the webhook call
cat -n .github/workflows/centralized-release.yml | sed -n '250,275p'

Repository: wuji-technology/.github

Length of output: 974


🏁 Script executed:

#!/bin/bash
# Try to use --fail-with-body flag directly to verify it exists
echo "=== Testing --fail-with-body flag ==="
curl --help 2>&1 | wc -l
echo "Help output line count above"

# Try with a different approach - check man page or curl documentation
echo ""
echo "=== Checking curl documentation for --fail ==="
curl --help 2>&1 | grep -A2 -E "\-\-fail" | head -20

# Let's also check what happens with curl on 4xx/5xx responses
echo ""
echo "=== Testing curl default behavior on HTTP errors ==="
# Using httpbin.org's status endpoint (returns specific status codes)
# This shows that curl returns 0 even on 404
(curl -s -w "Exit code would be: %{http_code}\n" "https://httpbin.org/status/404" 2>&1 || echo "Curl exited with code: $?") | head -5

Repository: wuji-technology/.github

Length of output: 456


🏁 Script executed:

# Check if --fail-with-body is documented in curl man pages or online docs
# For curl 7.88.1 specifically
echo "=== Checking curl version history for --fail-with-body ==="
curl --version | head -1
# According to curl changelog, --fail-with-body was added in 7.76.0
# Our version 7.88.1 should support it
# Let's verify by checking actual curl behavior

echo ""
echo "=== Try using --fail flag with older curl syntax ==="
curl --help 2>&1 | grep -E "^\s+--fail" -A 1

Repository: wuji-technology/.github

Length of output: 382


建议添加 curl 失败条件,确保通知失败时工作流正确报错。

当前 curl 对 4xx/5xx 仍返回 0,导致通知发送失败但工作流显示成功。可以使用 --fail 标志让 curl 在 HTTP 错误时立即失败。

🔧 建议调整
-          curl -X POST "$WEBHOOK_URL" \
-            -H "Content-Type: application/json" \
-            -d "$JSON_PAYLOAD"
+          curl --fail -X POST "$WEBHOOK_URL" \
+            -H "Content-Type: application/json" \
+            -d "$JSON_PAYLOAD"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
curl -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD"
curl --fail -X POST "$WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD"
🤖 Prompt for AI Agents
In @.github/workflows/centralized-release.yml around lines 264 - 266, The curl
invocation that posts to $WEBHOOK_URL with -d "$JSON_PAYLOAD" should treat HTTP
4xx/5xx as failures; update the curl command (the existing curl -X POST
"$WEBHOOK_URL" -H "Content-Type: application/json" -d "$JSON_PAYLOAD") to
include --fail (and optionally --show-error) and ensure the step fails on a
non‑zero exit (e.g., let the CI shell propagate curl's exit code or add an
explicit check) so the workflow errors when the notification request fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants