使用 edgeone 命令行工具部署 EdgeOne Pages 静态网站。
本插件支持两种使用方式:插件变量方式 和 Script 方式。
通过 settings 传入参数,插件自动执行部署命令,无需手动编写 script。
| 参数 | 必填 | 说明 | 默认值 |
|---|---|---|---|
project_name | ✅ | EdgeOne Pages 项目名称 | - |
api_token | ✅ | EdgeOne Pages API Token | - |
directory | ❌ | 部署目录路径 | . |
environment | ❌ | 部署环境,preview 为预发环境,不填为生产 | 生产环境 |
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: 部署预发环境
image: tencentcom/deploy-eopages:latest
settings:
project_name: landing-page-demo
api_token: $EDGEONE_PAGES_API_TOKEN
directory: ./dist
environment: preview
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: 部署生产环境
image: tencentcom/deploy-eopages:latest
settings:
project_name: landing-page-demo
api_token: $EDGEONE_PAGES_API_TOKEN
directory: ./dist
直接使用 script 编写自定义的 edgeone 命令,适合需要灵活控制部署流程的场景。
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:
- 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
edgeone pages 提供了预发以及生产两个环境,刚好契合 cnb 的自定义部署功能,可以在 .cnb/tag_deploy 中配置环境。
environments:
- name: staging
description: staging环境发布
- name: production
description: 生产环境发布
require:
- environmentName: staging
after: 60
API Token 为敏感信息,推荐使用密钥仓库来存储,然后在流水线中引用:
# envs.yml
EDGEONE_PAGES_API_TOKEN: mRH1***wu0C