staging build update better makefile

* filter all branches for staging
* build each staging branch/pr as a directory

Signed-off-by: Toshaan Bharvani <toshaan@vantosh.com>
remotes/1691128968110617338/master
Toshaan Bharvani 2 years ago
parent 44ef89bfbf
commit b650aeb9d5

@ -1,9 +1,10 @@
#!Makefile #!Makefile


SHELL:=bash
HUGO=hugo-extended HUGO=hugo-extended
BUILDNAME:=$(shell git rev-parse --abbrev-ref HEAD) BUILDNAME:=$(shell git rev-parse --abbrev-ref HEAD)
BASEURL:=$(shell basename `pwd` | sed 's/_/./g') BASEURL:=$(shell basename `pwd` | sed 's/_/./g')
BRANCHES:=$(shell git branch -r | sed 's/origin\///g' | sed 's/pr\//pr-/' | sed '/HEAD/d' | sed '/master/d' | sed '/main/d')
BRANCHNAMES:=$(foreach branch,$(BRANCHES),$(branch))


default all: build default all: build


@ -16,16 +17,11 @@ build:


.PHONY: build-staging .PHONY: build-staging
build-staging: build-staging:
@rm -rf public/ rm -rf builds/*
branches=$(git branch -r) @for branch in $(BRANCHNAMES) ; do \
for branch in $(branches); do echo -e "Building branch \e[1;33m"$${branch}"\e[0m" ; \
if [ $(branch) != '->' ] && [ $(branch) != 'origin/HEAD' ] && [ $(branch) != 'origin/master' ] && [ $(branch) != 'origin/main' ]; then git checkout $${branch} ; \
echo $(branch) $(HUGO) --environment=production --minify --templateMetrics --baseURL https://$(BASEURL)/$${branch}/ --destination builds/$${branch} ; \
branchname=$(basename $branch)
git checkout $(branchname)
$(HUGO) --environment=production --minify --templateMetrics --baseURL https://$(BASEURL)/$(branchname)/ --destination builds/$(branchname)
fi
done done


.PHONY: test .PHONY: test

Loading…
Cancel
Save