Publishing posts becomes seamless as everything is in the same world of consuming, evolving and publishing.
Meher Howji··· Likes
To publish from Obsidian, a few prerequisites need to be in place.
Obsidian is configured to be able to push to GitHub using the Obsidian Git plugin
Next.js or Gatsby site has a directory from which you are reading your markdown files for rendering. I use Contentlayer to simplify this process.
You can set up a GitHub Action with the following script. Although the script looks pretty long, it’s pretty simple if you look at each step.
Here's a step-by-step explanation of what it does:
The workflow is triggered when a push event occurs on the “master” branch.
The "copy-files" job runs on the latest Ubuntu environment.
Check out the Obsidian Vault using the actions/checkout@v3 action.
Find all Markdown files tagged with 'meherhowji.com' in the repository and copy them to the "publish_ready" directory.
Rename the copied .md files to .mdx and convert their filenames to lowercase with dashes instead of spaces.
Check if there are any files in the "publish_ready" directory, and the count is saved as an output.
The "Status in Obsidian" step displays the number of pages to be published and lists their names.
If there are files to publish, it clones the "aerosailor-next.git" repository.
The files from "publish_ready" are copied to the "aerosailor-next/data/articles/" directory.
Check the git status of the "aerosailor-next" repository and determine if any changes are to be committed.
If changes are staged, the "Publish to MeherHowji.com" step pushes the changes to the "aerosailor-next" repository with a commit message indicating automatic publication from Obsidian.
In summary, this GitHub Actions workflow automates the process of publishing Markdown files tagged with 'meherhowji.com' to the MeherHowji.com website. It checks for changes in the files, copies them to the target repository, and commits the changes if necessary, triggering the deployment to the website.
Check out the How I Built My Website post for more details on the libraries and utilities I have used.