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
2121 with :
2222 ref : Admin
2323 path : logseq-source
24+ fetch-depth : 0
2425
2526 - name : Checkout Web-live branch (Quartz site)
2627 uses : actions/checkout@v4
@@ -35,45 +36,97 @@ jobs:
3536 SOURCE="logseq-source/pages"
3637 DEST="quartz-site/content"
3738
38- # Count files before
39+ # Count files before sync
3940 before=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4041
41- # Remove stale .md files (deleted from Logseq) but keep index.md
42+ # Delete stale notes (keeps index.md intact)
4243 find "$DEST" -name "*.md" ! -name "index.md" -delete
4344
44- # Copy all .md files from Logseq pages/
45+ # Copy notes from Admin branch to Web-live branch
4546 cp -r "$SOURCE"/. "$DEST"/
4647
47- # Count files after
48- after=$(find "../ $DEST" -name "*.md" ! -name "index.md" | wc -l)
48+ # Count files after sync
49+ after=$(find "$DEST" -name "*.md" ! -name "index.md" | wc -l)
4950 echo "files_before=$before" >> $GITHUB_OUTPUT
5051 echo "files_after=$after" >> $GITHUB_OUTPUT
5152
52- - name : Check for changes
53+ - name : Inject Git Timestamps into Frontmatter
54+ run : |
55+ cat << 'EOF' > inject_dates.py
56+ import os
57+ import subprocess
58+ import re
59+
60+ source_dir = 'logseq-source/pages'
61+ dest_dir = 'quartz-site/content'
62+
63+ if not os.path.exists(source_dir):
64+ exit(0)
65+
66+ for filename in os.listdir(source_dir):
67+ if not filename.endswith('.md'):
68+ continue
69+
70+ dest_path = os.path.join(dest_dir, filename)
71+ if not os.path.exists(dest_path):
72+ continue
73+
74+ created_cmd = ['git', 'log', '--diff-filter=A', '--format=%aI', '-1', '--', f"pages/{filename}"]
75+ updated_cmd = ['git', 'log', '-1', '--format=%aI', '--', f"pages/{filename}"]
76+
77+ try:
78+ created = subprocess.run(created_cmd, cwd='logseq-source', capture_output=True, text=True, check=True).stdout.strip()
79+ updated = subprocess.run(updated_cmd, cwd='logseq-source', capture_output=True, text=True, check=True).stdout.strip()
80+ except subprocess.CalledProcessError:
81+ continue
82+
83+ if not created or not updated:
84+ continue
85+
86+ with open(dest_path, 'r', encoding='utf-8') as f:
87+ content = f.read()
88+
89+ inject = ""
90+ if not re.search(r'^date:\s+', content, flags=re.MULTILINE):
91+ inject += f"date: {created}\n"
92+ if not re.search(r'^lastmod:\s+', content, flags=re.MULTILINE):
93+ inject += f"lastmod: {updated}\n"
94+
95+ if inject:
96+ if content.startswith('---'):
97+ content = content.replace('---', f'---\n{inject}', 1)
98+ else:
99+ content = f'---\n{inject}---\n' + content
100+
101+ with open(dest_path, 'w', encoding='utf-8') as f:
102+ f.write(content)
103+ EOF
104+ python3 inject_dates.py
105+
106+ - name : Check for changes in content/
53107 id : changes
54108 run : |
55109 cd quartz-site
56110 git add content/
57111 if git diff --staged --quiet; then
58112 echo "has_changes=false" >> $GITHUB_OUTPUT
59- echo "No content changes detected — skipping commit ."
113+ echo "No changes detected — skipping deploy ."
60114 else
61115 changed=$(git diff --staged --name-only | wc -l)
62116 echo "has_changes=true" >> $GITHUB_OUTPUT
63117 echo "changed_count=$changed" >> $GITHUB_OUTPUT
64118 fi
65119
66- - name : Commit and push to Web-live
120+ - name : Commit and push changes to Web-live
67121 if : steps.changes.outputs.has_changes == 'true'
68122 run : |
69123 cd quartz-site
70124 git config user.name "github-actions[bot]"
71125 git config user.email "github-actions[bot]@users.noreply.github.com"
72-
73- CHANGED=${{ steps.changes.outputs.changed_count }}
74126 COMMIT_SHA=$(cd ../logseq-source && git rev-parse --short HEAD)
75127
76- git commit -m "sync: $CHANGED file(s) updated from Logseq (Admin@$COMMIT_SHA)"
128+ git add content/
129+ git commit -m "sync: ${{ steps.changes.outputs.changed_count }} file(s) updated from Logseq (Admin@$COMMIT_SHA)"
77130 git push origin Web-live
78131
79132 - name : Summary
82135 echo "### ✅ Sync complete" >> $GITHUB_STEP_SUMMARY
83136 echo "- **Files before:** ${{ steps.sync.outputs.files_before }}" >> $GITHUB_STEP_SUMMARY
84137 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
138+ echo "- **Changed files :** ${{ steps.changes.outputs.changed_count }}" >> $GITHUB_STEP_SUMMARY
139+ echo "- Content files pushed to **Web-live**. Vercel will build and deploy ." >> $GITHUB_STEP_SUMMARY
87140 else
88141 echo "### ⏭️ No changes" >> $GITHUB_STEP_SUMMARY
89142 echo "Content was already up to date — no commit made." >> $GITHUB_STEP_SUMMARY
0 commit comments