Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 2.37 KB

File metadata and controls

77 lines (53 loc) · 2.37 KB

Next.js Project Deployment to EdgeOne Pages

This is a Next.js template project that uses GitHub Actions for building and deployment to EdgeOne Pages.

Project Overview

This project provides a starter template for Next.js applications, integrating GitHub Actions workflows and automatic deployment functionality.

Complete .github/workflows/deploy.yml configuration is as follows:

name: Build and Deploy

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      
      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
      
      - name: Install dependencies
        run: npm install
      
      - name: Build project
        run: npm run build
      
      - name: Deploy to EdgeOne Pages
        run: npx edgeone pages deploy --name my-edgeone-pages-project --token ${{ secrets.EDGEONE_API_TOKEN }}
        env:
          EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }}

Step 1: GitHub Actions Build

This project uses GitHub Actions for automated building. When code is pushed to the main branch, it triggers the following build process:

  1. Checkout the repository code
  2. Setup Node.js 20 environment
  3. Install project dependencies
  4. Build the project using Next.js

Step 2: EdgeOne Pages Deployment

After the build completes, the project is automatically deployed to EdgeOne Pages through the following process:

  1. The EdgeOne command line tool is used for deployment:
    npx edgeone pages deploy --name my-edgeone-pages-project --token ${{ secrets.EDGEONE_API_TOKEN }}

Setting Up the Repository Secret

To deploy to EdgeOne Pages, you need to add your EDGEONE_API_TOKEN as a repository secret in GitHub:

  1. Navigate to your GitHub repository
  2. Go to "Settings" > "Secrets and variables" > "Actions"
  3. Click "New repository secret"
  4. Name: EDGEONE_API_TOKEN
  5. Value: Your EdgeOne API token

Obtain your EDGEONE_API_TOKEN from EdgeOne Pages by visiting: https://edgeone.ai/document/177158578324279296

References