Use Github Actions
Follow the guide in this section, you can quickly integrate Actions workflows in your Github repository to enable automated build and deploy to EdgeOne Pages.
Set Github Repository Secret
To run this Action, you need to create a Secret in your GitHub repository:
access your GitHub repository page
go to "Settings" > "Secrets and variables" > "Actions"
Click "New repository secret"
Enter EDGEONE_API_TOKEN in "Name" Enter the value of EdgeOne API token in "Secret"
The complete
.github/workflows/deploy.yml
configuration is as follows:name: Build and Deployon:push:branches:- mainjobs:build-and-deploy:runs-on: ubuntu-lateststeps:- name: Checkout repositoryuses: actions/checkout@v4- name: Setup Node.jsuses: actions/setup-node@v4with:node-version: '22.11.0' # Select a suitable Node.js version- name: Install dependenciesrun: npm install- name: Build projectrun: npm run build- name: Deploy to EdgeOne Pagesrun: npx edgeone pages deploy <outputDirectory> -n <projectName> -t ${{ secrets.EDGEONE_API_TOKEN }} [-e <env>]env:EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}
Note:
npx edgeone pages deploy
Parameter description:<outputDirectory>: The folder where the project building product resides (required)
-n, --name: The name of the project to be deployed. If the project does not exist, a new project will be created automatically (required)
-e, --env: Target deployment environment, available values: production or preview (default: production)
Note: Example: npx edgeone pages deploy ./dist -n project-name -t ${{ secrets.EDGEONE_API_TOKEN }}
Building with GitHub Actions
Place the
deploy.yml
file configuration in your project root directory. When code is pushed to the main branch, the following build process will be triggered:1. checkout to the target repository
2. Set Node.js version to 22.11.0
3. Install project dependencies
4. Build project
Deploy with EdgeOne Pages
After build complete, the project will be deployed to EdgeOne Pages via the following steps:
Generate the ./out directory during the build stage
Use EdgeOne command line tool to perform deployment:
npx edgeone pages deploy ./out -n my-edgeone-pages-project -t ${{ secrets.EDGEONE_API_TOKEN }}
Related documentation for Github Action: https://docs.github.com/en/actions