Optimising Git work flow with functions & aliases

For this example I'm automating elements of work flow in publishing Ghost post updates to github pages.

I'm utilising Buster to generate a static version of a ghost blog before pushing to github pages.

Located in user home directory, the .bash_profile can have functions added to it to optimise this otherwise fairly lengthy workflow allowing several commands to be grouped into one function. The .bash_profile can be edited with nano .bash_profile or preferred editor.

gitpushghost() {  
    buster generate --domain=http://127.0.0.1:2368
    cd static
    git add .
    git commit -m 'Update on the website at $(date)'
    git push
}

This function allows to simply enter gpg from within buster folder to update and publish in one function.

Given the nature of building a static site with buster each time a new post is added, the git commits will more often than not reference an update to content. The commit message has been automated to reflect this and time of update has been added dynamically with $(date).

To further optimise, an alias has been added.

alias gpg=gitpushghost  

Developmental work is tracked and committed separately before Buster integration.

More here:

ghost-on-github-pages

git-add-commit-and-push-commands-in-one

guide-to-terminal-aliases-and-functions

Show Comments