From 44ef89bfbf185bdc2f9209ab0396c3aa1501efd9 Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Thu, 14 Jul 2022 16:45:06 +0200 Subject: [PATCH] add staging build to make Signed-off-by: Toshaan Bharvani --- Makefile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Makefile b/Makefile index 320810c..03d3acb 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ #!Makefile +SHELL:=bash HUGO=hugo-extended +BUILDNAME:=$(shell git rev-parse --abbrev-ref HEAD) +BASEURL:=$(shell basename `pwd` | sed 's/_/./g') default all: build @@ -11,6 +14,20 @@ build: @find public/ -name '*.css' ! -name '*.gz' -type f -exec sh -c "gzip -c -9 < {} > {}.gz" \; @find public/ -name '*.js' ! -name '*.gz' -type f -exec sh -c "gzip -c -9 < {} > {}.gz" \; +.PHONY: build-staging +build-staging: + @rm -rf public/ + branches=$(git branch -r) + for branch in $(branches); do + if [ $(branch) != '->' ] && [ $(branch) != 'origin/HEAD' ] && [ $(branch) != 'origin/master' ] && [ $(branch) != 'origin/main' ]; then + echo $(branch) + branchname=$(basename $branch) + git checkout $(branchname) + + $(HUGO) --environment=production --minify --templateMetrics --baseURL https://$(BASEURL)/$(branchname)/ --destination builds/$(branchname) + fi + done + .PHONY: test test: clean $(HUGO) --environment=development --minify