The Goal of This Process
I really hate repeating myself. And that includes repeatedly performing the same actions on my computer. With this new website on DigitalOcean, there are many repetitive process that I would like to automate. Consider this workflow:
- Create or modify a page on the site
- Save the changes
- Commit changes to local git repository
- Check out revisions on a developmental server
- Push changes to the production server
- Rebuild production site to include the changes
- Reindex the site so that Algolia picks up the changes
This workflow is shown graphically in the Mermaid figure below.
I definitely do not want to do this manually every time! So, I have written a bash script to take care of it for me. Here is my “update” bash script:
#! /bin/bash #=============================================================== # UPDATE # This script updates my website after editing its contents # Dr. Clifton Franklund # Ferris State University # 2018, MIT #=============================================================== # Check for commit message if [ $# -eq 0 ] then # default commit message message="Updated website contents" else # first passed argument is message message=$1 fi # update my git repository git add . git status git commit -m "$message" # send update to DigitalOcean droplet git push droplet master # reindex the website jekyll algolia push
I stored this script in my /bin directory (which is on my path) and changed permissions with chmod 755 to make it executable. Not when I type
update "This is a sample commit", all saved changes are committed to git, published to my droplet, built as a new site, and reindexed. All automatically. I smile a little every time I do this - it is a small dopamine hit, I think. Feel free to copy, modify, and/or use this script for your own projects.