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

使用 Echobell 为 GitHub Actions 失败配置即时 Webhook 通知,让 CI/CD 流水线的异常第一时间触达你——推送通知或来电提醒,秒级送达。

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

CI 失败的邮件和 Slack 消息很容易被忽略。Echobell 通知 Action 可以直接将 Webhook 告警推送到你的手机——普通构建用推送通知,生产环境失败直接来电——让流水线异常无处遁形。

配置步骤

1. 创建 Echobell 频道

  1. 下载 Echobell 并登录
  2. 创建一个频道,命名如"GitHub CI/CD 告警"
  3. 从频道设置中复制 Webhook URL
  4. 在 GitHub 仓库中:Settings → Secrets and variables → Actions → New repository secret
  5. 命名为 ECHOBELL_WEBHOOK_URL,粘贴 URL

2. 添加到工作流

基础配置(单 job 工作流):

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:

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。详见来电通知

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

相关资源