---
title: "再也不错过 GitHub Actions 失败：用 Echobell 实现即时告警"
description: "使用 Echobell 为 GitHub Actions 失败配置即时 Webhook 通知，让 CI/CD 流水线的异常第一时间触达你——推送通知或来电提醒，秒级送达。"
date: 2025-04-26
author: Nooc
authorAvatarLink: /images/avatars/nooc.webp
authorLink: https://nooc.me
tags:
  - Echobell
  - GitHub Actions
  - CI/CD
  - webhook notifications
  - developer alerts
---

# 再也不错过 GitHub Actions 失败：用 Echobell 实现即时告警

CI 失败的邮件和 Slack 消息很容易被忽略。[Echobell 通知 Action](https://github.com/weelone/echobell-action) 可以直接将 Webhook 告警推送到你的手机——普通构建用推送通知，生产环境失败直接来电——让流水线异常无处遁形。

## 配置步骤

### 1. 创建 Echobell 频道

1. [下载 Echobell](https://apps.apple.com/app/apple-store/id6743597198?pt=128151925&ct=blog-github-actions-notifications-zh&mt=8) 并登录
2. 创建一个频道，命名如"GitHub CI/CD 告警"
3. 从频道设置中复制 Webhook URL
4. 在 GitHub 仓库中：**Settings → Secrets and variables → Actions → New repository secret**
5. 命名为 `ECHOBELL_WEBHOOK_URL`，粘贴 URL

### 2. 添加到工作流

**基础配置**（单 job 工作流）：

```yaml
name: Build and Test

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Build
        run: npm run build

      - name: Test
        run: npm test

      - name: Notify on Failure
        if: failure()
        uses: weelone/echobell-action@v1
        with:
          webhook-url: ${{ secrets.ECHOBELL_WEBHOOK_URL }}
```

**多 job 流水线** — 使用专门的通知 job，依赖所有关键 job：

```yaml
name: Deploy Pipeline

on:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run Tests
        run: npm test

  build:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build
        run: npm run build

  deploy:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - name: Deploy
        run: npm run deploy

  notify_on_failure:
    runs-on: ubuntu-latest
    needs: [test, build, deploy]
    if: failure()
    steps:
      - name: Send Failure Notification
        uses: weelone/echobell-action@v1
        with:
          webhook-url: ${{ secrets.ECHOBELL_WEBHOOK_URL }}
```

专门的通知 job 可以将级联失败合并为一条告警，而不是触发多条重复通知。

## 使用技巧

**通知标题**应能回答：哪里失败了、是什么、什么时候。建议使用类似 `❌ Main Branch CI Failed` 或 `🚨 Deploy Pipeline Down - Production` 的格式。

**按严重程度使用不同频道。** 普通 CI 告警用标准频道，生产环境失败用设置为**来电**的第二个频道。让不同工作流指向不同的 Webhook URL。详见[来电通知](/en/blog/grafana-call-notification)。

**与团队共享频道。** 为全团队都需要关注的 CI/CD 失败创建一个频道，为仅基础设施相关的问题创建独立频道。Echobell 的[共享频道](/en/features/channels)允许团队成员用自己的通知偏好订阅——无需每个人都单独配置 Webhook。

## 相关资源

- [Webhook 文档](/en/docs/webhook) — 完整的 Webhook API 参考
- [模板](/en/docs/template) 和 [条件](/en/docs/conditions) — 自定义通知内容和过滤规则
- [Grafana 来电通知](/en/blog/grafana-call-notification) — 监控系统的来电告警
- [WebhookMCP 通知](/en/blog/get-notified-with-webhook-mcp) — AI 任务完成提醒
- 功能文档：[频道](/en/features/channels)、[Webhooks](/en/features/webhooks)、[邮件触发](/en/features/email-triggers)、[来电通知](/en/features/call-notifications)
