Skip to main content

Automate Static Web Workflow

·2 mins

There are certain steps I do after I create a post. First I push my change into a git repository, then I will build the website using Hugo. Once the latest build are made, I have to upload it to Google Cloud Storage. Then I have to change the metadata on the mainpage (index.html). This process become tedious especially if you have do it manually one by one. The easiest way to automate the process in Windows is using batch file. Below is the content of my batch file:

REM Commit change using git
git add .
git commit -m "Update Website"

REM Push to github
git push origin master

REM Push to Gitea server @ local home
git push home master

REM Generate static web
hugo

REM Sync change to Google Cloud Storage
call gsutil -m rsync -r -d public gs://www.henthom.com

REM Change the metadata of all files
call gsutil setmeta -h "Cache-Control:no-cache,max-age=0" gs://www.henthom.com/*

For your information REM in bat file is a comment. I explain most of the commands function using REM as a comment. I am using call command so the batch file will not break even if gsutil command throw an error. After creating a post I just have to run my build.bat file and wait patiently. So far thats the only commands I use to publish my static website. If you have any question just leave a comment below.

Henry Thomas
Author
Henry Thomas
Just a guy with a pen and a dream