coding_agent

阶段四:项目初始化与工作流

项目初始化

使用模板

参考 PLAN 模板 → 建立新项目的标准流程。

Astro 项目初始化

npm create astro@latest my-project
cd my-project
npm run dev

常见项目结构

my-project/
├── src/
│   ├── pages/        # 页面路由
│   ├── components/  # 组件
│   ├── layouts/     # 布局
│   └── styles/      # 样式
├── public/          # 静态资源
├── astro.config.mjs
└── package.json

Git Flow

基础 Git 工作流

# 创建新分支
git checkout -b feature/my-feature

# 开发... 提交
git add .
git commit -m "feat: add new feature"

# Push
git push -u origin feature/my-feature

# 创建 PR
gh pr create

Commit Message 规范

遵循 Conventional Commits:type: description

  • feat: 新功能
  • fix: Bug 修复
  • refactor: 重构
  • docs: 文档
  • chore: 杂项

GitHub Actions 部署

GitHub Pages 自动部署

GitHub Actions 可以自动构建并部署到 GitHub Pages。

Workflow 示例

name: Deploy to GitHub Pages

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - name: Install and Build
        run: |
          npm ci
          npm run build
      - name: Deploy
        uses: actions/deploy-pages@v4

详细配置参考 GitHub Actions 自动化部署实战

相关案例

快速参考

命令参考 →  |  规则参考 →  |  博客 →