Last active
January 12, 2025 04:15
-
-
Save aczw/7b31a8a94398478f2f13867deb46dc75 to your computer and use it in GitHub Desktop.
GitHub Actions workflow for syncing Obsidian vault and Quartz (using Bun). Replace the placeholder values as necessary.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update vault content | |
on: | |
schedule: | |
- cron: '0 11 * * MON' # Run every Monday at 11 AM UTC (6 AM EST, 7 AM EDT) | |
workflow_dispatch: | |
jobs: | |
update_vault_content: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone aczw/<VAULT_REPO> | |
uses: actions/checkout@v4.2.2 | |
with: | |
repository: 'aczw/<VAULT_REPO>' | |
ref: main | |
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
path: <VAULT_REPO> | |
- name: Clone this repo | |
uses: actions/checkout@v4.2.2 | |
with: | |
ref: v4 | |
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} | |
path: <QUARTZ_REPO> | |
- name: Delete everything in content/ except index.md | |
run: | | |
cd <QUARTZ_REPO> | |
mv content/index.md . | |
rm -rf content | |
mkdir content | |
mv index.md content | |
- name: Copy over media and files | |
run: | | |
cd <VAULT_REPO> | |
echo "----- Copying over public-only attachments" | |
cp -vr <PUBLIC_ATTACHMENTS_FOLDER> ../<QUARTZ_REPO>/content | |
echo -e "\n----- Copying over Markdown files" | |
cp -vr <YOUR_NOTES_FOLDER>/. ../<QUARTZ_REPO>/content | |
cd ../<QUARTZ_REPO>/content | |
mv <PUBLIC_ATTACHMENTS_FOLDER> _files | |
# ^ Include this last line if you want to rename your public folder | |
- name: Print out current state of filesystem | |
run: | | |
echo "----- Folder: <QUARTZ_REPO>/" | |
cd <QUARTZ_REPO> | |
ls | cat | |
echo -e "\n----- Folder: <QUARTZ_REPO>/content/" | |
ls content | cat | |
echo -e "\n----- Folder: <QUARTZ_REPO>/content/_files" | |
ls content/_files | cat | |
# ^ NOTE: this uses the renamed folder name from above | |
- name: Install Bun just to run literally two commands | |
uses: oven-sh/setup-bun@v2.0.1 | |
with: | |
bun-version: latest | |
- name: Install dependencies | |
run: | | |
cd <QUARTZ_REPO> | |
bun i | |
- name: Setup Git config (user and email), necessary for commits | |
run: | | |
git config --global user.name "Porter Robinson" | |
git config --global user.email "hello@example.com" | |
- name: Sync Quartz repo | |
run: | | |
cd <QUARTZ_REPO> | |
bun quartz sync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment