Using Github Actions
With this guide, you can quickly integrate the Actions workflow in your GitHub repository to enable automated build and deploy to EdgeOne Pages.
Set GitHub Repository Secrets
To run this Actions, you need to create repository Secrets in GitHub:
Access your GitHub repository webpage.
Go to Settings > Secrets and variables > Actions.
Click New repository secret.
Enter EDGEONE_API_TOKEN in "Name" and the EdgeOne API token value in "Secret".
Deploying Trunk Code Changes
The complete
.github/workflows/deploy.yml configuration is as follows:name: Build and Deploy# Trigger deployment on branch push to main trunkon: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 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 }}
Configure the above
deploy.yml file in your project root directory. When code is pushed to the main branch, it will trigger the following build process:1. Check out to the target repository.
2. Set the Node.js version to 22.11.0.
3. Install project dependencies.
4. Build project.
After build complete, return to console view to check the build link, or go to Actions > All workflows > Build and Deploy in the current repository to view the Deploy to EdgeOne Pages node.

Deploying Preview URL before Code Merge
The complete
.github/workflows/deploy.yml configuration is as follows:name: Build and Deployon:pull_request_target:types: [opened]jobs:Deploy-Preview:runs-on: ubuntu-latestpermissions:pull-requests: writesteps:- uses: actions/checkout@v4- name: Setup Node.jsuses: actions/setup-node@v4with:node-version: '22.11.0' # select suitable Node.js version- name: Install dependenciesrun: npm install- name: Build projectrun: npm run build- name: Deploy to EdgeOne Pagesid: deployrun: |echo "Deploying to EdgeOne Pages..."DEPLOY_OUTPUT=$(npx edgeone pages deploy ./.next -n next-mix-render-template -t ${{ secrets.EDGEONE_TOKEN }} -e preview 2>&1)DEPLOY_URL=$(echo "$DEPLOY_OUTPUT" | grep "EDGEONE_DEPLOY_URL=" | cut -d'=' -f2-)echo "DEPLOY_URL=$DEPLOY_URL" >> $GITHUB_OUTPUTPROJECT_ID=$(echo "$DEPLOY_OUTPUT" | grep "EDGEONE_PROJECT_ID=" | cut -d'=' -f2-)echo "PROJECT_ID=$PROJECT_ID" >> $GITHUB_OUTPUTDEPLOY_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")echo "DEPLOY_END_TIME=$DEPLOY_END_TIME" >> $GITHUB_OUTPUTenv:EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_TOKEN }}- name: Enable PR comments # Support preview URL deployment before code mergeuses: thollander/actions-comment-pull-request@v2with:message: |🚀 **EdgeOne Pages deployment complete**| Project | Preview Link | Project ID | Update Time ||---|---|---|---|| [${{ github.event.repository.name }}](https://console.tencentcloud.com/edgeone/pages/project/${{ steps.deploy.outputs.PROJECT_ID }}/deploy) | [🔗 Click to Preview](${{ steps.deploy.outputs.DEPLOY_URL }}) | ${{ steps.deploy.outputs.PROJECT_ID }} | ${{ steps.deploy.outputs.DEPLOY_END_TIME }} |
Configure the above
deploy.yml file in your project root directory. When a pull request is created, it will trigger the following build process:1. Check out to the target repository.
2. Set the Node.js version to 22.11.0.
3. Install project dependencies.
4. Build project.
5. The pull request comment area will display EdgeOne deployment successful information. You can review page changes before merging code.


Note:
npx edgeone pages deploy parameter description:<outputDirectory>: The folder where the project build product is located (required).
-n, --name: The project name to be deployed. A new project will be created automatically if it does not exist (required).
-e, --env: The target environment to deploy. Available values: production or preview (default production).
Example: npx edgeone pages deploy ./dist -n project-name -t ${{ secrets.EDGEONE_API_TOKEN }}.
EdgeOne Pages Deployment
After build complete, the project will be deployed to EdgeOne Pages via the following steps:
Build stage generates ./out directory
Use the EdgeOne command line tool to deploy:
npx edgeone pages deploy ./out -n my-edgeone-pages-project -t ${{ secrets.EDGEONE_API_TOKEN }}
