Hi all,
I am new here, and I am using Hugo for my personal website that has private and public repo.
private: main source code
public: Hugo-generated code.
Initially, when creating a new release, I had to copy the Hugo-generated files manually to the public repository, so I created a simple script to automate deployments.
It was built in bash, but if you think this could be potentially useful to others, I’ll continue development and make it much better.
Any feedback or suggestions would be appreciated.
Script workflow
- Builds the site with Hugo
- Deletes old content in public repository (preserving excluded files)
- Copies new content to public repository
- Switches to or creates gh-pages branch
- Commits changes with version as message
- Pushes to remote repository (if --push option is used)
Usage examples
Deploy version 1.2.3
./hugo-deploy.sh 1.2.3
Deploy and push to remote
./hugo-deploy.sh 1.2.3 --push
List previous deployments
./hugo-deploy.sh list
Revert (undo) version 1.2.3 by going back to the previous version
./hugo-deploy.sh revert 1.2.3
Revert a specific commit by going back to the previous commit
./hugo-deploy.sh revert abc123f
Revert and force push to remote
./hugo-deploy.sh revert 1.2.3 --push