⚡ Automation

Auto Publish Watchlist

📅 February 2026 🏷 git · github · automation · watchlist · templater · symlink
Saves an Obsidian watchlist note, stages the linked repo file, commits only if changes exist, then pushes automatically to GitHub.

Edit the watchlist note inside Obsidian, run the template, and the rest happens automatically:

The actual repository file is a symlink pointing into your Obsidian vault, so editing the note edits the repo file directly. No manual git workflow needed afterward.

// pushwatchlist.js

const { exec } = require("child_process");

async function pushwatchlist() {

    return new Promise((resolve, reject) => {

        const cmd =
            'cd /d C:\\Users\\indig\\OneDrive\\Desktop\\Saptak && ' +
            'git add projects/watchlist/watchlist.md && ' +
            'git diff --cached --quiet || ' +
            '(git commit -m "watchlist update" && git push origin main)';

        exec(cmd, (error, stdout, stderr) => {

            console.log(stdout);

            if (stderr) {
                console.error(stderr);
            }

            // git diff --cached --quiet returns exit code 1 when changes exist
            // so ignore that specific case
            if (
                error &&
                !stdout.includes("nothing to commit")
            ) {
                reject(stderr || error.message);
                return;
            }

            resolve(stdout || "done");
        });
    });
}

module.exports = pushwatchlist;

The Templater Trigger

Run this from Obsidian. It saves the current file, waits one second so the filesystem settles, then calls the Node.js helper.

<%*
try {

    await app.commands.executeCommandById("editor:save-file");

    await new Promise(r => setTimeout(r, 1000));

    await tp.user.pushwatchlist();

    new Notice("✅ Watchlist pushed");

} catch (err) {

    console.error(err);

    new Notice(`❌ ${err}`, 10000);
}
%>

How The System Works

The workflow depends on a symlink.

Obsidian Note
      ↓
Symlink
      ↓
Git Repository File
      ↓
Git Add → Commit → Push

Because the repo file is linked directly into the vault:

The Templater script becomes the entire deployment pipeline.


The Git Flow

The command chain runs in this order:

git add projects/watchlist/watchlist.md
git diff --cached --quiet
git commit -m "watchlist update"
git push origin main

What Each Step Does

git add — stages the watchlist file only.

git diff --cached --quiet — checks whether staged changes exist.

That exit code is intentionally used as control flow.

git commit only runs if changes exist.

git push origin main only runs after a successful commit.


Required Setup

Windows example:

mklink "C:\repo\projects\watchlist\watchlist.md" "C:\vault\watchlist.md"

After that:


2. Add The JS File To Templater Scripts

Place the JS file inside your Templater scripts folder.

Example:

Vault/
└── scripts/
    └── pushwatchlist.js

3. Enable User Scripts In Templater

Inside Templater settings:

Templater → User Scripts Folder Location

Point it at the scripts directory.


4. Run The Template

Run from:

Cmd/Ctrl + P

Then:

Templater: Replace templates in active file

Or bind it to a hotkey.


Notes