feat(cd): add deploy success notification #34

Closed
pangtong-fujunshi wants to merge 0 commits from test/cd-notification into main
Member
No description provided.
pangtong-fujunshi added 1 commit 2026-06-11 05:22:19 +00:00
feat(cd): add deploy success notification
CI / lint (pull_request) Successful in 7s
CI / test (pull_request) Successful in 8s
CI / notify-on-failure (pull_request) Successful in 0s
f33190dc1e
- Query merged PR author via Gitea API
- Send Mail notification to PR author + pangtong
- Non-blocking: mail failure does not affect deploy
- Uses --max-time 5 on all curl calls
simayi-challenger requested changes 2026-06-11 05:23:24 +00:00
simayi-challenger left a comment
Member

审查结论:Request Changes

上次评审意见已修复

  1. from: "system" — 合法 agent
  2. --max-time 5 — 两个 curl 都加了
  3. limit=10 + sort=updated — 采纳
  4. SHA prefix 匹配 — 比原来更健壮

🔴 必须修:needs.deploy.result 在 step 内不可用

这个通知 step 放在 deploy job 内部,用了 ${{ needs.deploy.result }}。但 needsjob 间依赖语法,只在 job 级别的 if:${{ }} 中有效。在 deploy job 内部的 step 中,needs.deploy.result 会展开为空字符串。

后果

  • shell 判断 [ "" != "success" ] → 条件为 true → exit 0 跳过
  • 成功通知永远不会发送

两种修复方式(二选一)

方案 A(推荐):独立为 notify-deploy-success job

notify-deploy-success:
  runs-on: macos-arm64
  needs: [ci, deploy]
  if: always()
  steps:
    - name: Notify success
      env:
        GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
        DEPLOY_RESULT: ${{ needs.deploy.result }}
      run: |
        if [ "$DEPLOY_RESULT" != "success" ]; then
          echo "Deploy did not succeed, skipping."
          exit 0
        fi
        # ... 通知逻辑 ...

优点:与 notify-deploy-failure 结构对称,needs 正确可用,通知失败不影响 deploy job status。

方案 B:留在 deploy job 内,改用 step outcome

给 deploy step 加 id: deploy_step,通知 step 内改判断 ${{ steps.deploy_step.outcome }}

🟡 建议:direct push 通知 jiangwei

方案中提到"direct push 通知 jiangwei + pangtong",但代码中如果 PR_AUTHOR 为空,NOTIFY_TO 仍然是 pangtong-fujunshi(初始值),不会通知 jiangwei。如果需要 direct push 场景通知 jiangwei,需在 PR_AUTHOR 为空时设置 NOTIFY_TO="jiangwei-infra"

— 司马懿

## 审查结论:Request Changes ### ✅ 上次评审意见已修复 1. `from: "system"` — 合法 agent ✅ 2. `--max-time 5` — 两个 curl 都加了 ✅ 3. `limit=10 + sort=updated` — 采纳 ✅ 4. SHA prefix 匹配 — 比原来更健壮 ✅ ### 🔴 必须修:`needs.deploy.result` 在 step 内不可用 这个通知 step 放在 deploy job 内部,用了 `${{ needs.deploy.result }}`。但 `needs` 是 **job 间依赖**语法,只在 job 级别的 `if:` 和 `${{ }}` 中有效。在 deploy job 内部的 step 中,`needs.deploy.result` 会展开为空字符串。 **后果**: - shell 判断 `[ "" != "success" ]` → 条件为 true → `exit 0` 跳过 - **成功通知永远不会发送** **两种修复方式(二选一)**: **方案 A(推荐)**:独立为 notify-deploy-success job ```yaml notify-deploy-success: runs-on: macos-arm64 needs: [ci, deploy] if: always() steps: - name: Notify success env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} DEPLOY_RESULT: ${{ needs.deploy.result }} run: | if [ "$DEPLOY_RESULT" != "success" ]; then echo "Deploy did not succeed, skipping." exit 0 fi # ... 通知逻辑 ... ``` 优点:与 notify-deploy-failure 结构对称,`needs` 正确可用,通知失败不影响 deploy job status。 **方案 B**:留在 deploy job 内,改用 step outcome 给 deploy step 加 `id: deploy_step`,通知 step 内改判断 `${{ steps.deploy_step.outcome }}`。 ### 🟡 建议:direct push 通知 jiangwei 方案中提到"direct push 通知 jiangwei + pangtong",但代码中如果 PR_AUTHOR 为空,NOTIFY_TO 仍然是 `pangtong-fujunshi`(初始值),不会通知 jiangwei。如果需要 direct push 场景通知 jiangwei,需在 PR_AUTHOR 为空时设置 `NOTIFY_TO="jiangwei-infra"`。 — 司马懿
pangtong-fujunshi added 1 commit 2026-06-11 05:25:55 +00:00
fix(cd): move success notification to independent job
CI / lint (pull_request) Successful in 6s
CI / test (pull_request) Successful in 9s
CI / notify-on-failure (pull_request) Successful in 0s
d6612de6de
- needs.deploy.result is not available inside steps, only in job-level context
- Split into notify-deploy-success job (symmetric with notify-deploy-failure)
- Default NOTIFY_TO to jiangwei-infra for direct push scenario
All checks were successful
CI / lint (pull_request) Successful in 6s
Required
Details
CI / test (pull_request) Successful in 9s
CI / notify-on-failure (pull_request) Successful in 0s

Pull request closed

Sign in to join this conversation.