name: CI

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        run: |
          git clone https://cantyonion.site/git/cantyonion/WebIndex.git

      - name: Set up Node.js
        uses: https://gitea.com/actions/setup-node@v4
        with:
          node-version: '22'  # 可以根据需要选择 Node.js 版本

      - name: Set NPM Mirror
        run: npm config set registry https://registry.npmmirror.com

      - name: Install dependencies
        working-directory: WebIndex
        run: npm install

      - name: Build project
        working-directory: WebIndex
        run: npm run build

      - name: Compress build artifacts
        run: |
          mkdir -p artifacts
          zip -r artifacts/build.zip WebIndex/dist/
      
      - name: Upload Release Asset
        uses: https://gitea.com/actions/gitea-release-action@v1
        with:
          files: |-
            artifacts/build.zip
          