方案
实现从obsidian通过插件实现笔记软件同步到github 最后使用action 方式进行发布
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
| name: pages-build-deployment
on: push: branches: [ master ] workflow_dispatch: inputs: manual_trigger: description: 'Manual deployment trigger' required: false default: 'manual'
permissions: contents: write
jobs: build-and-deploy: runs-on: ubuntu-latest
steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 submodules: recursive
- name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '18' cache: 'npm'
- name: Display environment info run: | echo "Node version: $(node --version)" echo "NPM version: $(npm --version)" echo "Working directory: $(pwd)"
- name: Install dependencies run: | npm install hexo-cli -g npm ci --production=false
- name: Verify theme installation run: | echo "Checking theme installation..." if [ ! -d "node_modules/hexo-theme-butterfly" ]; then echo "❌ Error: hexo-theme-butterfly not found!" exit 1 fi echo "✅ Theme installed successfully"
- name: Clean cache run: | echo "Cleaning Hexo cache..." hexo clean || true
- name: Generate static files run: | echo "Generating static files..." hexo generate echo "✅ Generation completed"
- name: Verify build output run: | echo "=== Build Verification ===" echo "Public directory contents:" ls -la public/ echo "" if [ ! -d "public" ]; then echo "❌ Error: public directory not found!" exit 1 fi if [ ! -f "public/index.html" ]; then echo "❌ Error: index.html not found!" exit 1 fi echo "✅ index.html exists" if [ -f "public/index.html" ]; then echo "✅ Checking for article links in index.html..." if grep -q "posts/" public/index.html; then echo "✅ Article links found in index.html" else echo "⚠️ Warning: No article links found in index.html" fi fi FILE_COUNT=$(find public -type f | wc -l) echo "📊 Total files generated: $FILE_COUNT" if [ "$FILE_COUNT" -lt 10 ]; then echo "⚠️ Warning: Generated file count seems low ($FILE_COUNT files)" fi
- name: Upload build artifact uses: actions/upload-artifact@v4 with: name: hexo-build-output path: public/ retention-days: 7
- name: Deploy to GitHub Pages id: deployment uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public publish_branch: gh-pages force_orphan: true user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com' commit_message: 'Deploy Hexo blog - ${{ github.event.head_commit.message }}' force: true
- name: Deployment summary if: success() run: | echo "=== 🎉 Deployment Summary ===" echo "✅ Build successful!" echo "✅ Deployment to gh-pages completed!" echo "🌐 Blog URL: https://noeverer.github.io" echo "📅 Deployment time: $(date)" echo "👤 Triggered by: ${{ github.actor }}" echo "📝 Commit: ${{ github.sha }}"
- name: Deployment failure notification if: failure() run: | echo "=== ❌ Deployment Failed ===" echo "❌ Deployment to gh-pages failed!" echo "Please check the logs above for details." echo "GitHub Actions URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|