Using CNB Plugin
With this section's guide, you can quickly integrate Cloud Native Build (CNB) into the process for automated build and deploy to EdgeOne Pages.
Configuring a Private Key
Use the CNB key repository for storage, then refer to it in the pipeline. The envs.yml content is as follows:
EDGEONE_API_TOKEN: oJTlMUq9**********NYzKFIw=
The complete .cnb.yml is configured as follows:
# trigger: push to master branchmain:push:# Import environment variables from private repository:# See: https://docs.cnb.cool/en/build/env.html#importing-environment-variables- imports: https://cnb.cool/***/-/blob/main/envs.ymlstages:# Build Current Project- name: Build Current Projectimage: node:20script: node -v && npm install && npm run build# Deploy build output to EdgeOne Pages# The ./dist directory is generated in the previous build step# See: https://www.npmjs.com/package/edgeone- name: Deploy to EdgeOne Pagesimage: node:20script: npx edgeone pages deploy <outputDirectory> -n <projectName> -t $EDGEONE_API_TOKEN
Note:
npx edgeone pages deploy parameter description:<outputDirectory>: The folder where the project build product resides (required).
-n, --name: Project name that needs to be deployed. A new project will be created automatically if the project does not exist (required).
-e, --env: Target environment for deployment, available values: production or preview (default production).
Example: npx edgeone pages deploy ./dist -n project-name -t $EDGEONE_API_TOKEN.
Cloud Native Build (CNB)
When code is pushed to the main branch, it triggers the following build process:
1. Import required environment variables.
2. Build project using Node.js 20 environment.
3. Deploy the build output to Pages.
Deploying EdgeOne Pages
The project will be automatically deployed to Pages through the following process after build complete.
1. Build stage generates ./dist directory.
2. Use EdgeOne command line tool
edgeone pages deploy to deploy.