I thought about switching my blog from Octopress to Ghost. I like having control
over the content that I’m publishing since they’re just literally markdown files (*.md)
and has no database backend. What I dislike about Octopress is the publishing aspect where I
have to issue a rake deploy
every time I publish content. I was actually able to manage and minimize the multi-steps into running one small script. But I still have to do one step which is unacceptable.
The deployment should be painless and automated, period.. The directory should be able to automatically detect/pick up any file changes (new or update post)
and issue a generate command to convert the markdown files into HTML. Since the files
are locally created (synced to Dropbox), I need a way to automate it. My solution is to let the Windows Task Scheduler manage and run it every 24 hours. I wrote a console app and
the code looks like something below.
The dir
is basically pointing to the root of the Octopress blog that I want published. Having this in the app.config
gives me the flexibility to switch directory if my Dropbox is in a different location. The /C
tells the command prompt to terminate after execution, and the push.sh
is a shell script that I wrote a while back that generates HTML files, commit to local Git and deploy to Heroku server all in one shot.
var process = new ProcessStartInfo
{
WorkingDirectory = ConfigurationManager.AppSettings["dir"],
FileName = "cmd.exe",
Arguments = @"/C push.sh",
CreateNoWindow = false
};
var proceed = Process.Start(process);
proceed.CloseMainWindow();
proceed.Close();
Environment.Exit(0);
}
If you’re curious, the push.sh
file looks like:
#!/bin/sh
# push.sh : publish and commit with a single command
rake generate && rake deploy
git add .
git commit -am "'date'" && git push heroku master
The script above is a bash script (*.sh) so if you’re running it in a Windows environment, I found that installing Git and using Git Bash is the easiest way to run bash scripts.