> For AI agents: the complete documentation index is available at https://www.tteam.icu/llms.txt, the full documentation bundle is available at https://www.tteam.icu/llms-full.txt.

# cloudflare pages钉钉通知


AI SummaryAI Generated

这篇文章介绍了如何为 Cloudflare Pages 增加钉钉部署通知，解决构建成功或失败无法及时获知的问题。
- 作者基于 Slack 通知项目二次开发，使其支持钉钉 Webhook。
- GitHub Actions 会检测 Cloudflare Pages 状态并推送消息，文中列出了所需机密变量和配置方式。

## 开始

我的纯静态网站[博客](https://blog.tteam.icu)、[关于我](https://www.tteam.icu)、[笔记](https://note.tteam.icu)等网站都使用Cloudflare Pages进行编译和部署

但我发现Cloudflare没有集成通知功能，无论是编译完成还是失败，我都无法及时获知

随后我在网上查找类似功能，找到了[cloudflare-pages-slack-notification](https://github.com/arddluma/cloudflare-pages-slack-notification)

但测试后发现它不支持钉钉webhook，因此我基于该仓库进行了二次开发并翻译

[项目地址](https://github.com/buyfakett/cloudflare-pages-dingding-webhook)

## 配置

### github

原理是github的workflows自动检测cf的状态来推送

```yaml
name: dingding_webhook
on: push
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Await CF Pages and send Slack notification
        id: cf-pages
        uses: buyfakett/cloudflare-pages-dingding-webhook@v2
        with:
          # Uncomment these two lines if you wish to use the Global API Key (Not recommended!)
          # accountEmail: ${{ secrets.CF_ACCOUNT_EMAIL  }}
          # apiKey: ${{ secrets.CF_API_KEY  }}

          # Use an API token (Recommended!)
          apiToken: ${{ secrets.CF_API_TOKEN }}
          accountId: ${{ secrets.CF_ACC_ID  }}
          # CloudFlare Pages project name
          project: ${{ secrets.CF_PAGES_PROJECT  }}
          dingWebHookKey: ${{ secrets.DING_WEBHOOK_KEY }}
          # Add this if you want GitHub Deployments (see below)
          githubToken: ${{ secrets.GITHUB_TOKEN }}
```

### 机密说明

CF\_API\_TOKEN: Cloudflare API 令牌。[如何创建 Cloudflare API 令牌](https://dash.cloudflare.com/profile/api-tokens)

CF\_ACC\_ID: CloudFlare 帐户 ID。(访问 [Cloudflare 的仪表板](https://dash.cloudflare.com/)，您将在 URL 中找到帐户 ID)

CF\_PAGES\_PROJECT: CloudFlare Pages 项目名称。(你可以在[这里](https://dash.cloudflare.com/%7Byour_account_id%7D/workers-and-pages) 找到它)

DING\_WEBHOOK\_KEY: 钉钉中创建WEBHOOK机器人, 关键字填入`项目`

## 通知截图

![](https://img.tteam.icu/i/2024/11/30/itqdxp-3.webp)

![](https://img.tteam.icu/i/2024/11/30/lyaat9-3.webp)
