name: Build and Deploy Quartz Site on: schedule: - cron: '0 6 * * 1' # 每周一早上 6 点(UTC)执行一次定时任务 push: branches: - main # 当 main 分支有新提交时触发工作流 jobs: build-and-deploy: environment: prod runs-on: ubuntu-latest # 使用最新的 Ubuntu 运行环境 steps: - name: Checkout Quartz Repository uses: actions/checkout@v3 # 检出当前仓库的代码 - name: Set up Node.js 20 uses: actions/setup-node@v3 # 设置 Node.js 环境 with: node-version: '20' # 使用 Node.js 20 版本 - name: Clone x-eden Repository run: | # 克隆 x-eden 仓库到临时目录 git clone "${{ secrets.GITEA_REPO_CLONE }}" /tmp/x-eden - name: Prepare Content Directory (simple allowlist copy) run: | set -euo pipefail rm -rf content mkdir -p content # 仅拷贝允许公开的目录(不存在就跳过,不报错) for dir in \ "00-knowledge" \ "10-formal-sciences" \ "16-computer-science" \ "20-natural-sciences" \ "30-social-sciences" \ "40-professional" \ "60-writing" \ "70-future" do if [ -d "/tmp/x-eden/$dir" ]; then cp -r "/tmp/x-eden/$dir" "content/" fi done # 单文件:README.md -> index.md,并插入 frontmatter if [ -f /tmp/x-eden/README.md ]; then cp /tmp/x-eden/README.md content/index.md sed -i '1d' content/index.md || true sed -i '1i ---\ntitle: 数字花园\n---' content/index.md || true fi - name: Sanity Check (ensure nothing private slipped in) run: | set -euo pipefail # 这些目录永远不应出现在 content 中 bad_paths=$(ls -d \ content/50-personal \ content/80-project \ content/90-obsidian \ content/91-attachments \ content/92-archive \ content/99-inbox \ 2>/dev/null || true) if [ -n "$bad_paths" ]; then echo "ERROR: Found private folders in content:" echo "$bad_paths" exit 1 fi - name: Install Dependencies and Build Site run: | npm ci npx quartz build - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public cname: x-eden.zopiya.com user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com'