From 9d2e15d56d45b60e64fae82915f48c7c79ae203e Mon Sep 17 00:00:00 2001 From: niuweili <957905827@qq.com> Date: Mon, 3 Mar 2025 12:13:38 +0800 Subject: [PATCH 1/7] feat: update template --- .github/workflows/npm-publish.yml | 4 +- ...32\347\237\245\346\250\241\346\235\277.md" | 85 +++++++------------ scripts/upload.mjs | 2 +- 3 files changed, 32 insertions(+), 59 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 2725a542..455ed035 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,13 +1,13 @@ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages -name: Publish package and upload cdn +name: 测试环境-发布文档 on: release: types: [created] push: - branches: [main] + branches: [test] jobs: publish-npm: diff --git "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" index 854b5709..2351f5cf 100644 --- "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" +++ "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" @@ -239,6 +239,8 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi 以下为各通知渠道具体说明。 +
+ ## 飞书应用 --- 您需要预先配置 `集成中心-即时消息-飞书` 集成,才能发送消息卡片。如果不设置自定义内容,将采用系统默认模板,渲染全部标签信息: @@ -281,8 +283,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi {{if (index .Labels "mode")}}mode:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}runbook_url:{{toHtml (index .Labels "runbook_url")}}{{end}} ``` +
- +
## 钉钉应用 --- @@ -325,7 +328,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi {{if (index .Labels "mode")}}**mode**:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}**runbook_url**:{{index .Labels "runbook_url"}}{{end}} ``` +
+
## 企业微信应用 --- @@ -363,7 +368,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi **注意,企业微信限制了卡片长度,在模板渲染区域,您最多可以渲染不超过 8 行内容,超过 8 行的部分将被隐藏** +
+
## Slack 应用 --- @@ -408,8 +415,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi {{if (index .Labels "mode")}}*mode*:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}*runbook_url*:{{index .Labels "runbook_url"}}{{end}} ``` +
- +
## Microsoft Teams 应用 --- @@ -454,56 +462,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi {{if (index .Labels "mode")}}**mode**:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}**runbook_url**:{{index .Labels "runbook_url"}}{{end}} ``` +
- - - - -## Microsoft Teams 应用 ---- -您需要预先配置 `集成中心-即时消息- Microsoft Teams` 集成,才能发送消息卡片。如果不设置自定义内容,将采用系统默认模板,仅渲染常见标签信息: - -``` -{{if .Description}}**description** :{{toHtml .Labels.body_text .Description}}{{end}} -{{if .Labels.resource}}**resource** : {{toHtml (joinAlertLabels . "resource" ", ")}}{{end}} -{{range $k, $v := .Labels}} -{{if not (in $k "resource" "body_text" "body_text_with_table")}}**{{$k}}** : {{toHtml $v}}{{end}}{{end}} -``` - - -如下图所示: - -drawing - -如果您期望仅展示关键标签信息,可以参照下边的代码段: - -- 我们列出了一些常见标签,您可自行删减; -- 消息可以发送长度为 28KB 左右字节,超出后报错; -- 在 Microsoft Teams 应用中,系统会自动帮您删除(因标签不存在导致的)渲染空行,您可放心配置 - -``` -{{if (index .Labels "resource")}}**resource**:{{toHtml (joinAlertLabels . "resource" ", ")}}{{end}} -{{if (index .Labels "metric")}}**metric**:{{index .Labels "metric"}}{{end}} -{{if (index .Labels "prom_ql")}}**prom_ql**:{{toHtml (index .Labels "prom_ql")}}{{end}} -{{if (index .Labels "trigger_value")}}**trigger_value**:{{index .Labels "trigger_value"}}{{end}} -{{if (index .Labels "host_ql")}}**host_ql**:{{index .Labels "host_ql"}}{{end}} -{{if (index .Labels "region")}}**region**:{{index .Labels "region"}}{{end}} -{{if (index .Labels "cluster")}}**cluster**:{{index .Labels "cluster"}}{{end}} -{{if (index .Labels "business")}}**business**:{{index .Labels "business"}}{{end}} -{{if (index .Labels "service")}}**service**:{{index .Labels "service"}}{{end}} -{{if (index .Labels "env")}}**env**:{{index .Labels "env"}}{{end}} -{{if (index .Labels "type")}}**type**:{{index .Labels "type"}}{{end}} -{{if (index .Labels "topic")}}**topic**:{{index .Labels "topic"}}{{end}} -{{if (index .Labels "cpu")}}**cpu**:{{index .Labels "cpu"}}{{end}} -{{if (index .Labels "device")}}**device**:{{index .Labels "device"}}{{end}} -{{if (index .Labels "path")}}**path**:{{index .Labels "path"}}{{end}} -{{if (index .Labels "fstype")}}**fstype**:{{index .Labels "fstype"}}{{end}} -{{if (index .Labels "name")}}**name**:{{index .Labels "name"}}{{end}} -{{if (index .Labels "mode")}}**mode**:{{index .Labels "mode"}}{{end}} -{{if (index .Labels "runbook_url")}}**runbook_url**:{{index .Labels "runbook_url"}}{{end}} -``` - - +
## 飞书机器人 --- @@ -526,8 +487,10 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi 分派人员:{{range .Responders}}@{{.PersonName}} {{end}}{{end}}
详情:{{.DetailUrl}} ``` +
+
## 钉钉机器人 --- @@ -552,8 +515,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi ---
[详情]({{.DetailUrl}})|[认领]({{.DetailUrl}}?ack=1) ``` +
- +
## 企业微信机器人 --- @@ -575,11 +539,13 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi > 分派人员:{{range .Responders}}@{{.PersonName}} {{end}}{{end}}
[详情]({{.DetailUrl}})|[认领]({{.DetailUrl}}?ack=1) ``` +
- +
## Telegram 机器人 --- + - 配置国内能访问的Telegram服务地址; - 消息`最大长度为4096字符,超出后不发送`; - 如果文本中包含`
`,渲染时会`先删除空行,再将
替换为换行符`; @@ -599,8 +565,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi
[详情]({{.DetailUrl}})|[认领]({{.DetailUrl}}?ack=1) ``` +
- +
## Slack 机器人 --- @@ -622,6 +589,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi -----
<{{.DetailUrl}}|详情>|<{{.DetailUrl}}?ack=1|认领> ``` +
+ +
## Zoom 机器人 --- @@ -721,8 +691,10 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi ] } ``` +
+
## 短信 --- @@ -731,8 +703,9 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi ``` 您有故障待处理:{{toHtml .Title}},协作空间:{{.ChannelName}},等级:{{.IncidentSeverity}}{{if gt .AlertCnt 1}},共聚合{{.AlertCnt}}条告警{{end}} ``` +
- +
## 邮件 --- @@ -827,4 +800,4 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi drawing - +
diff --git a/scripts/upload.mjs b/scripts/upload.mjs index e23bf8b9..78cab7be 100644 --- a/scripts/upload.mjs +++ b/scripts/upload.mjs @@ -8,7 +8,7 @@ import OpenApi from "@alicloud/openapi-client"; dotenv.config(); const localDir = "./dist/iife"; // 本地文件夹路径 -const ossDir = "/docs"; // 将数字转换为字符串并添加前缀 +const ossDir = "/docs/test"; // 上传到oss的文件路径 const client = new OSS({ region: process.env.CDN_REGION, From bdd61b404b55b7a71c71b67d703bee09a5de3e1a Mon Sep 17 00:00:00 2001 From: niuweili <957905827@qq.com> Date: Mon, 3 Mar 2025 14:43:30 +0800 Subject: [PATCH 2/7] feat: beta-5 --- .../3. Configure Flashduty/3.7 Templates.md | 21 +++++++++++++++++++ package.json | 2 +- scripts/upload.mjs | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/flashduty/en/3. Configure Flashduty/3.7 Templates.md b/flashduty/en/3. Configure Flashduty/3.7 Templates.md index 2f27be34..271d426a 100644 --- a/flashduty/en/3. Configure Flashduty/3.7 Templates.md +++ b/flashduty/en/3. Configure Flashduty/3.7 Templates.md @@ -237,6 +237,8 @@ CloseTime | int64 | No | Close time, EndTime is alert recovery time, CloseTime i Below are specific instructions for each notification channel. +
+ ## Feishu/Lark App --- You need to configure `Integration Center - IM - Feishu/Lark` integration first to send message cards. If custom content is not set, the system default template will be used to render all label information: @@ -280,6 +282,9 @@ If you want to display only key label information, you can refer to the code sni {{if (index .Labels "mode")}}mode:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}runbook_url:{{toHtml (index .Labels "runbook_url")}}{{end}} ``` +
+ +
## Dingtalk App --- @@ -322,6 +327,9 @@ If you want to display only key label information, you can refer to the code sni {{if (index .Labels "mode")}}**mode**:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}**runbook_url**:{{index .Labels "runbook_url"}}{{end}} ``` +
+ +
## WeCom App --- @@ -358,6 +366,9 @@ As shown below: **Note: WeCom limits card length. In the template rendering area, you can render up to 8 lines of content. Content beyond 8 lines will be hidden** +
+ +
## Slack App --- @@ -401,6 +412,9 @@ If you want to display only key label information, you can refer to the code sni {{if (index .Labels "mode")}}*mode*:{{index .Labels "mode"}}{{end}} {{if (index .Labels "runbook_url")}}*runbook_url*:{{index .Labels "runbook_url"}}{{end}} ``` +
+ +
## Zoom Bot --- @@ -500,6 +514,10 @@ If you want to display only key label information, you can refer to the code sni ] } ``` +
+ + +
## SMS --- @@ -508,6 +526,9 @@ If custom content is not set, the system default template will be used for notif ``` You have a pending incident: {{toHtml .Title}}, Channel: {{.ChannelName}}, Severity: {{.IncidentSeverity}}{{if gt .AlertCnt 1}}, Grouped {{.AlertCnt}} alerts{{end}} ``` +
+ +
## Email --- diff --git a/package.json b/package.json index 1234fbb9..97d84122 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flashduty-knowledge-base", - "version": "1.2.4", + "version": "1.2.4-beta.5", "description": "flashduty knowledge base", "type": "module", "scripts": { diff --git a/scripts/upload.mjs b/scripts/upload.mjs index 78cab7be..fc1a4214 100644 --- a/scripts/upload.mjs +++ b/scripts/upload.mjs @@ -8,7 +8,7 @@ import OpenApi from "@alicloud/openapi-client"; dotenv.config(); const localDir = "./dist/iife"; // 本地文件夹路径 -const ossDir = "/docs/test"; // 上传到oss的文件路径 +const ossDir = "/test/docs"; // 上传到oss的文件路径 const client = new OSS({ region: process.env.CDN_REGION, From d6b476a84860f701f936f1d99aa9fdc49a6a9f43 Mon Sep 17 00:00:00 2001 From: alick-liming Date: Tue, 4 Mar 2025 15:25:49 +0800 Subject: [PATCH 3/7] feishu webhook card post message --- ...32\347\237\245\346\250\241\346\235\277.md" | 204 +++++++++++++++++- 1 file changed, 203 insertions(+), 1 deletion(-) diff --git "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" index 2351f5cf..6ac250fe 100644 --- "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" +++ "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" @@ -468,12 +468,214 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi ## 飞书机器人 --- -飞书机器人仅支持发送纯文本消息。 +飞书机器人支持消息卡片,富文本和普通文本三种格式,默认模版是消息卡片格式。 +- msg_type 字段在消息卡片和富文本中必填,否则当成普通文本格式发送 - 消息`最大长度为4000字节,超出后截断发送`; - 如果文本中包含`
`,渲染时会`先删除空行,再将
替换为换行符`; - 如果不设置自定义内容,将采用系统默认模板,仅展示关键信息: +1. 消息卡片 +msg_type 必填,值为 interactive +``` +{ + "msg_type": "interactive", + "card": { + "config": { + "wide_screen_mode": true, + "enable_forward": true + }, + "header": { + "template": "{{if eq .IncidentSeverity "Critical"}}red{{else if eq .IncidentSeverity "Warning"}}orange{{else}}yellow{{end}}", + "title": { + "content": "{{fireReason .}}INC #{{.Num}} {{toHtml .Title}}", + "tag": "plain_text" + } + }, + "elements": [{ + "tag": "div", + "fields": [{ + "text": { + "tag": "lark_md", + "content": "**🏢 协作空间:**{{if .ChannelName}}{{.ChannelName}}{{else}}无{{end}}" + } + }, + { + "text": { + "tag": "lark_md", + "content": "**{{if eq .IncidentSeverity "Critical"}}🔴{{else if eq .IncidentSeverity "Warning"}}⚠️{{else}}ℹ️{{end}} 严重程度:**{{.IncidentSeverity}}" + } + }, + { + "text": { + "tag": "lark_md", + "content": "**⏰ 触发时间:**{{date "2006-01-02 15:04:05" .StartTime}}{{if gt .AlertCnt 1}}" + } + }, + { + "text": { + "tag": "lark_md", + "content": "**🔔 聚合告警:**{{.AlertCnt}}条 {{end}}{{if .Labels.resource}}" + } + }, + { + "tag": "div", + "text": { + "tag": "lark_md", + "content": "**📌 告警对象:**{{toHtml (joinAlertLabels . "resource" ",")}} {{end}}{{if .Description}}" + } + }, + { + "tag": "div", + "text": { + "tag": "lark_md", + "content": "**🔍 故障描述:**{{.Description}}{{end}}{{if gt (len .Responders) 0}}" + } + }, + { + "tag": "div", + "text": { + "tag": "lark_md", + "content": "**👨‍💻 处理人员:**{{range .Responders}}@{{.PersonName}} {{end}}{{end}}" + } + } + ] + }, + { + "tag": "hr" + }, + { + "tag": "action", + "actions": [{ + "tag": "button", + "text": { + "tag": "plain_text", + "content": "故障详情" + }, + "type": "primary", + "url": "{{.DetailUrl}}" + }, + { + "tag": "button", + "text": { + "tag": "plain_text", + "content": "认领" + }, + "type": "primary", + "url": "{{.DetailUrl}}?ack=1" + } + ] + }] + } +} +``` + +2. 富文本 +msg_type 必填,值为 post +``` +{ + "msg_type": "post", + "post": { + "zh_cn": { + "title": "{{if eq .IncidentSeverity "Critical"}}🔴{{else if eq .IncidentSeverity "Warning"}}⚠️{{else}}ℹ️{{end}} {{fireReason .}}INC #{{.Num}} {{toHtml .Title}}", + "content": [ + [{ + "tag": "text", + "text": "🏢 " + }, { + "tag": "text", + "text": "协作空间:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{if .ChannelName}}{{.ChannelName}}{{else}}无{{end}}\n" + }], + [{ + "tag": "text", + "text": "{{if eq .IncidentSeverity "Critical"}}🔴{{else if eq .IncidentSeverity "Warning"}}⚠️{{else}}ℹ️{{end}} " + }, { + "tag": "text", + "text": "严重程度:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{.IncidentSeverity}}\n", + "text_type": "{{if eq .IncidentSeverity "Critical"}}bold{{end}}" + }], + [{ + "tag": "text", + "text": "⏰ " + }, { + "tag": "text", + "text": "触发时间:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{date "2006-01-02 15:04:05" .StartTime}}\n" + }], + {{if gt .AlertCnt 1}}[{ + "tag": "text", + "text": "🔔 " + }, { + "tag": "text", + "text": "聚合告警:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{.AlertCnt}}条\n" + }],{{end}} + {{if .Labels.resource}}[{ + "tag": "text", + "text": "📋 " + }, { + "tag": "text", + "text": "告警对象:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{toHtml (joinAlertLabels . "resource" ", ")}}\n" + }],{{end}} + {{if .Description}}[{ + "tag": "text", + "text": "📝 " + }, { + "tag": "text", + "text": "描述:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{toHtml .Description}}\n" + }],{{end}} + {{if gt (len .Responders) 0}}[{ + "tag": "text", + "text": "👨‍💻 " + }, { + "tag": "text", + "text": "处理人员:", + "text_type": "bold" + }, { + "tag": "text", + "text": "{{range .Responders}}@{{.PersonName}} {{end}}\n" + }],{{end}} + [{ + "tag": "a", + "href": "{{.DetailUrl}}", + "text": "故障详情" + },{ + "tag": "text", + "text": " " + },{ + "tag": "a", + "href": "{{.DetailUrl}}?ack=1", + "text": "认领" + }] + ] + } + } +} +``` + +3. 普通文本 ``` {{fireReason .}}INC #{{.Num}} {{toHtml .Title}} ----- From 8c17551c88e0a388ca8c07a3ea7cb03a3ed81ad5 Mon Sep 17 00:00:00 2001 From: alick-liming Date: Wed, 5 Mar 2025 14:01:44 +0800 Subject: [PATCH 4/7] feishu webhook card post message --- ...7\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" | 1 - 1 file changed, 1 deletion(-) diff --git "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" index 6ac250fe..e88e98b1 100644 --- "a/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" +++ "b/flashduty/zh/3. \351\205\215\347\275\256Flashduty/3.7 \351\205\215\347\275\256\351\200\232\347\237\245\346\250\241\346\235\277.md" @@ -472,7 +472,6 @@ CloseTime | int64 | 否 | 关闭时间,EndTime 为告警恢复时间,CloseTi - msg_type 字段在消息卡片和富文本中必填,否则当成普通文本格式发送 - 消息`最大长度为4000字节,超出后截断发送`; -- 如果文本中包含`
`,渲染时会`先删除空行,再将
替换为换行符`; - 如果不设置自定义内容,将采用系统默认模板,仅展示关键信息: 1. 消息卡片 From a76843ed320d704b339577def63e2de867f194c2 Mon Sep 17 00:00:00 2001 From: niuweili <957905827@qq.com> Date: Wed, 5 Mar 2025 14:32:47 +0800 Subject: [PATCH 5/7] feat: 1.2.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97d84122..e45bcaa6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flashduty-knowledge-base", - "version": "1.2.4-beta.5", + "version": "1.2.5", "description": "flashduty knowledge base", "type": "module", "scripts": { From 2c385e3d0e240c5022f3ff010b6ac0bcc7da701c Mon Sep 17 00:00:00 2001 From: niuweili <957905827@qq.com> Date: Wed, 5 Mar 2025 14:36:05 +0800 Subject: [PATCH 6/7] feat: update actions --- .github/workflows/prod-publish.yml | 30 +++++++++++++++++++ .../{npm-publish.yml => test-publish.yml} | 0 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/prod-publish.yml rename .github/workflows/{npm-publish.yml => test-publish.yml} (100%) diff --git a/.github/workflows/prod-publish.yml b/.github/workflows/prod-publish.yml new file mode 100644 index 00000000..24e0f81e --- /dev/null +++ b/.github/workflows/prod-publish.yml @@ -0,0 +1,30 @@ +# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created +# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages + +name: Publish package and upload cdn + +on: + release: + types: [created] + push: + branches: [main] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + CDN_ACCESS_KEY: ${{ secrets.CDN_ACCESS_KEY }} + CDN_SECRET_KEY: ${{ secrets.CDN_SECRET_KEY }} + CDN_BUCKET: ${{ secrets.CDN_BUCKET }} + CDN_REGION: ${{ secrets.CDN_REGION }} + CDN_ENDPOINT: ${{ secrets.CDN_ENDPOINT }} + CDN_URL: ${{ secrets.CDN_URL }} \ No newline at end of file diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/test-publish.yml similarity index 100% rename from .github/workflows/npm-publish.yml rename to .github/workflows/test-publish.yml From d8ff06ead1424d579d93f7d4b1cd3cd79be75a12 Mon Sep 17 00:00:00 2001 From: niuweili <957905827@qq.com> Date: Wed, 5 Mar 2025 14:40:34 +0800 Subject: [PATCH 7/7] feat: add cdn dir --- .github/workflows/prod-publish.yml | 3 ++- .github/workflows/test-publish.yml | 1 + scripts/upload.mjs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prod-publish.yml b/.github/workflows/prod-publish.yml index 24e0f81e..6df8f295 100644 --- a/.github/workflows/prod-publish.yml +++ b/.github/workflows/prod-publish.yml @@ -27,4 +27,5 @@ jobs: CDN_BUCKET: ${{ secrets.CDN_BUCKET }} CDN_REGION: ${{ secrets.CDN_REGION }} CDN_ENDPOINT: ${{ secrets.CDN_ENDPOINT }} - CDN_URL: ${{ secrets.CDN_URL }} \ No newline at end of file + CDN_URL: ${{ secrets.CDN_URL }} + CDN_DIR: '/docs' \ No newline at end of file diff --git a/.github/workflows/test-publish.yml b/.github/workflows/test-publish.yml index 455ed035..ea76a213 100644 --- a/.github/workflows/test-publish.yml +++ b/.github/workflows/test-publish.yml @@ -28,3 +28,4 @@ jobs: CDN_REGION: ${{ secrets.CDN_REGION }} CDN_ENDPOINT: ${{ secrets.CDN_ENDPOINT }} CDN_URL: ${{ secrets.CDN_URL }} + CDN_DIR: '/test/docs' diff --git a/scripts/upload.mjs b/scripts/upload.mjs index fc1a4214..032ccf7d 100644 --- a/scripts/upload.mjs +++ b/scripts/upload.mjs @@ -8,7 +8,7 @@ import OpenApi from "@alicloud/openapi-client"; dotenv.config(); const localDir = "./dist/iife"; // 本地文件夹路径 -const ossDir = "/test/docs"; // 上传到oss的文件路径 +// const ossDir = "/test/docs"; // 上传到oss的文件路径 const client = new OSS({ region: process.env.CDN_REGION, @@ -43,7 +43,7 @@ async function uploadFiles() { } } - await uploadDir(localDir, ossDir); + await uploadDir(localDir, process.env.CDN_DIR); } catch (err) { console.error("Error uploading files:", err); }