|
| 1 | +# Next.js Project Deployment to EdgeOne Pages |
| 2 | + |
| 3 | +This is a Next.js template project that uses GitHub Actions for building and deployment to [EdgeOne Pages](https://edgeone.ai/products/pages). |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This project provides a starter template for Next.js applications, integrating GitHub Actions workflows and automatic deployment functionality. |
| 8 | + |
| 9 | +Complete `.github/workflows/deploy.yml` configuration is as follows: |
| 10 | + |
| 11 | +```yml |
| 12 | +name: Build and Deploy |
| 13 | + |
| 14 | +on: |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - main |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-and-deploy: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Setup Node.js |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: 20 |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: npm install |
| 34 | + |
| 35 | + - name: Build project |
| 36 | + run: npm run build |
| 37 | + |
| 38 | + - name: Deploy to EdgeOne Pages |
| 39 | + run: npx edgeone pages deploy ./out --name my-edgeone-pages-project --token ${{ secrets.EDGEONE_API_TOKEN }} |
| 40 | + env: |
| 41 | + EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }} |
| 42 | +``` |
| 43 | +
|
| 44 | +## Step 1: GitHub Actions Build |
| 45 | +
|
| 46 | +This project uses [GitHub Actions](https://docs.github.com/en/actions) for automated building. When code is pushed to the main branch, it triggers the following build process: |
| 47 | +
|
| 48 | +1. Checkout the repository code |
| 49 | +2. Setup Node.js 20 environment |
| 50 | +3. Install project dependencies |
| 51 | +4. Build the project using Next.js |
| 52 | +
|
| 53 | +## Step 2: EdgeOne Pages Deployment |
| 54 | +
|
| 55 | +After the build completes, the project is automatically deployed to [EdgeOne Pages](https://edgeone.ai/products/pages) through the following process: |
| 56 | +
|
| 57 | +1. The build phase generates the `./out` directory |
| 58 | +2. The EdgeOne command line tool is used for deployment: |
| 59 | + ```bash |
| 60 | + npx edgeone pages deploy ./out --name my-edgeone-pages-project --token ${{ secrets.EDGEONE_API_TOKEN }} |
| 61 | + ``` |
| 62 | + |
| 63 | +## Setting Up the Repository Secret |
| 64 | + |
| 65 | +To deploy to EdgeOne Pages, you need to add your `EDGEONE_API_TOKEN` as a repository secret in GitHub: |
| 66 | + |
| 67 | +1. Navigate to your GitHub repository |
| 68 | +2. Go to "Settings" > "Secrets and variables" > "Actions" |
| 69 | +3. Click "New repository secret" |
| 70 | +4. Name: `EDGEONE_API_TOKEN` |
| 71 | +5. Value: Your EdgeOne API token |
| 72 | + |
| 73 | +Obtain your `EDGEONE_API_TOKEN` from EdgeOne Pages by visiting: https://edgeone.ai/document/177158578324279296 |
| 74 | + |
| 75 | +# References |
| 76 | + |
| 77 | +- EdgeOne Pages Documentation: https://edgeone.ai/docs/pages |
| 78 | +- GitHub Actions Documentation: https://docs.github.com/en/actions |
0 commit comments