EdgeOne
EdgeOne Pages 是基于 Tencent EdgeOne 基础设施打造的全栈开发部署平台,提供从前端页面到动态 API 的无服务器部署体验,适用于构建营销网站、AI 应用等现代 Web 项目。通过边缘网络全球加速,确保应用获得快速、稳定的访问体验。
部署 EdgeOne Pages 插件
使用 edgeone 命令行工具部署 EdgeOne Pages 静态网站。
前置条件
- 已有 EdgeOne 账号并创建了 Pages 项目, 注意这个项目必须是 直接上传 类型
- 已获取 EdgeOne Pages API Token
部署流程说明
1. 简介
该插件使用 edgeone 命令行工具来部署 EdgeOne Pages 静态网站,基本用法如下:
edgeone pages deploy <directoryOrZip> -n <projectName> -t <API_TOKEN> [-e preview]
2. 环境部署配置
edgeone pages 提供了预发以及生产两个环境,刚好契合 cnb 的自定义部署功能,可以在 .cnb/tag_deploy 中配置环境。
environments:
- name: staging
description: staging环境发布
- name: production
description: 生产环境发布
require:
- environmentName: staging
after: 60
然后在 .cnb.yml 中配置对应的触发事件,EDGEONE_PAGES_API_TOKEN 请替换为您的真实 API Token。
API Token 一般为敏感信息,这里推荐使用密钥仓库来存储,然后在流水线中来引用。内容如下:
# envs.yml
EDGEONE_PAGES_API_TOKEN: mRH1***wu0C
预发环境部署
通过 tag_deploy.staging 触发,部署到预发环境:
tag_deploy.staging:
- imports: https://cnb.cool/***/-/blob/main/envs.yml
- stages:
- name: build
image: node:20-alpine
script: npm install && npm run build
- name: 部署我的 eo pages 预发环境
image: tencentcom/deploy-eopages:latest
script: |
edgeone pages deploy .dist -n landing-page-demo -e preview -t $EDGEONE_PAGES_API_TOKEN
生产环境部署
通过 tag_deploy.production 触发,部署到生产环境:
tag_deploy.production:
- imports: https://cnb.cool/***/-/blob/main/envs.yml
stages:
- name: build
image: node:20-alpine
script: npm install && npm run build
- name: 部署我的 eo pages 正式环境
image: tencentcom/deploy-eopages:latest
script: |
edgeone pages deploy ./dist -n landing-page-demo -t $EDGEONE_PAGES_API_TOKEN
参考文档
编辑此页 或