Custom Deployment Script

R blogdown development random-code-snippets

I don’t want to use Netlify for hosting, so I came up with this simple script to deploy my blog.

Robert M Flight
2017-12-27

TL;DR

Use a short bash script to do deployment from your own computer directly to your *.github.io domain.

Why?

So Yihui recommends using Netlify, or even Travis-CI in the Blogdown book. I wasn’t willing to setup a custom domain yet, and some of my posts involve a lot of personally created packages, etc, that I don’t want to debug installation on Travis. So, I wanted a simple script I could call on my laptop that would copy the /public directory to the repo for my github.io site, and then push the changes.

The Script

Here is the simple script I ended up using:

#!/bin/bash
org_dir=`pwd`
cd path/to/github.io/repo/
#rm -rf *
cp -Rfu path/to/blogdown/public/* .

git add *
commit_time=`date`
git commit -m "update at $commit_time"
git push origin master

cd $org_dir

It changes directories, because to push from a git repo I’m pretty sure you need to be in the directory, so it also makes sure to go back there at the end. It then copies the contents of /public to the repo, adds all the files, and then uses the current time-stamp as the commit message, and finally pushes all the updates.

Corrections

If you see mistakes or want to suggest changes, please create an issue on the source repository.

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. Source code is available at https://github.com/rmflight/researchBlog_distill, unless otherwise noted. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Flight (2017, Dec. 27). Deciphering Life: One Bit at a Time: Custom Deployment Script. Retrieved from https://rmflight.github.io/posts/2017-12-27-custom-deployment-script/

BibTeX citation

@misc{flight2017custom,
  author = {Flight, Robert M},
  title = {Deciphering Life: One Bit at a Time: Custom Deployment Script},
  url = {https://rmflight.github.io/posts/2017-12-27-custom-deployment-script/},
  year = {2017}
}