1- name : Sync Logseq → Quartz Content
1+ name : Sync Logseq → Quartz Content & Build
22
33on :
44 push :
55 branches :
66 - Admin
77 paths :
8- - " pages/**" # only runs when .md files in pages/ actually change
8+ - " pages/**" # runs when notes in pages/ change
99
1010 workflow_dispatch : # allows manual trigger from GitHub Actions UI
1111
1212jobs :
13- sync :
13+ sync-and-build :
1414 runs-on : ubuntu-latest
1515 permissions :
1616 contents : write
@@ -35,56 +35,98 @@ jobs:
3535 SOURCE="logseq-source/pages"
3636 DEST="quartz-site/content"
3737
38- # Count files before
38+ # Count files before sync
3939 before=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4040
41- # Remove stale .md files (deleted from Logseq) but keep index.md
41+ # Delete stale notes (keeps index.md intact)
4242 find "$DEST" -name "*.md" ! -name "index.md" -delete
4343
44- # Copy all .md files from Logseq pages/
44+ # Copy notes from Admin branch to Web-live branch
4545 cp -r "$SOURCE"/. "$DEST"/
4646
47- # Count files after
48- after=$(find "../ $DEST" -name "*.md" ! -name "index.md" | wc -l)
47+ # Count files after sync
48+ after=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4949 echo "files_before=$before" >> $GITHUB_OUTPUT
5050 echo "files_after=$after" >> $GITHUB_OUTPUT
5151
52- - name : Check for changes
52+ - name : Setup Node.js
53+ uses : actions/setup-node@v4
54+ with :
55+ node-version : 22
56+
57+ - name : Cache Node Modules
58+ uses : actions/cache@v4
59+ with :
60+ path : quartz-site/node_modules
61+ key : ${{ runner.os }}-node-modules-${{ hashFiles('quartz-site/package-lock.json') }}
62+ restore-keys : |
63+ ${{ runner.os }}-node-modules-
64+
65+ - name : Install Dependencies
66+ run : |
67+ cd quartz-site
68+ npm install
69+
70+ - name : Cache Quartz Build Cache
71+ uses : actions/cache@v4
72+ with :
73+ path : quartz-site/.quartz-cache
74+ key : ${{ runner.os }}-quartz-cache-${{ github.run_id }}
75+ restore-keys : |
76+ ${{ runner.os }}-quartz-cache-
77+
78+ - name : Build Quartz static site
79+ run : |
80+ cd quartz-site
81+ npx quartz build
82+
83+ - name : Check for changes in the generated static output
5384 id : changes
5485 run : |
5586 cd quartz-site
5687 git add content/
57- if git diff --staged --quiet; then
88+ if git diff --staged --quiet && [ -z "$(git status --porcelain public/)" ] ; then
5889 echo "has_changes=false" >> $GITHUB_OUTPUT
59- echo "No content changes detected — skipping commit ."
90+ echo "No changes detected — skipping deploy ."
6091 else
61- changed=$(git diff --staged --name-only | wc -l)
92+ changed=$(git status --porcelain public/ | wc -l)
6293 echo "has_changes=true" >> $GITHUB_OUTPUT
6394 echo "changed_count=$changed" >> $GITHUB_OUTPUT
6495 fi
6596
66- - name : Commit and push to Web-live
97+ - name : Commit and push source files to Web-live
6798 if : steps.changes.outputs.has_changes == 'true'
6899 run : |
69100 cd quartz-site
70101 git config user.name "github-actions[bot]"
71102 git config user.email "github-actions[bot]@users.noreply.github.com"
72-
73- CHANGED=${{ steps.changes.outputs.changed_count }}
74103 COMMIT_SHA=$(cd ../logseq-source && git rev-parse --short HEAD)
75104
76- git commit -m "sync: $CHANGED file(s) updated from Logseq (Admin@$COMMIT_SHA)"
105+ git add content/
106+ git commit -m "sync: content updated from Logseq (Admin@$COMMIT_SHA)"
77107 git push origin Web-live
78108
109+ - name : Deploy Pre-built site to Web-deploy branch
110+ if : steps.changes.outputs.has_changes == 'true'
111+ run : |
112+ cd quartz-site/public
113+ git init
114+ git config user.name "github-actions[bot]"
115+ git config user.email "github-actions[bot]@users.noreply.github.com"
116+ git checkout -b Web-deploy
117+ git add .
118+ git commit -m "deploy: pre-built from GitHub Actions"
119+ git remote add origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
120+ git push -f origin Web-deploy
121+
79122 - name : Summary
80123 run : |
81124 if [ "${{ steps.changes.outputs.has_changes }}" == "true" ]; then
82- echo "### ✅ Sync complete" >> $GITHUB_STEP_SUMMARY
125+ echo "### ✅ Build & Sync complete" >> $GITHUB_STEP_SUMMARY
83126 echo "- **Files before:** ${{ steps.sync.outputs.files_before }}" >> $GITHUB_STEP_SUMMARY
84127 echo "- **Files after:** ${{ steps.sync.outputs.files_after }}" >> $GITHUB_STEP_SUMMARY
85- echo "- **Changed:** ${{ steps.changes.outputs.changed_count }} file(s)" >> $GITHUB_STEP_SUMMARY
86- echo "- Vercel will now redeploy automatically." >> $GITHUB_STEP_SUMMARY
128+ echo "- Vercel will deploy instantly from **Web-deploy** branch." >> $GITHUB_STEP_SUMMARY
87129 else
88130 echo "### ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
89- echo "Content was already up to date — no commit made." >> $GITHUB_STEP_SUMMARY
131+ echo "Content was already up to date — no commit or deploy made." >> $GITHUB_STEP_SUMMARY
90132 fi
0 commit comments