Created
February 3, 2020 21:23
-
-
Save victoriadrake/132f9aa40ce9ccee90aae62f27427332 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.POSIX: | |
DESTDIR=public | |
HUGO_VERSION=0.58.3 | |
OPTIMIZE = find $(DESTDIR) -not -path "*/static/*" \( -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' \) -print0 | \ | |
xargs -0 -P8 -n2 mogrify -strip -thumbnail '1000>' | |
.PHONY: all | |
all: get_repository clean get build test deploy | |
.PHONY: get_repository | |
get_repository: | |
@echo "π Getting Pages repository" | |
git clone https://github.com/victoriadrake/victoriadrake.github.io.git $(DESTDIR) | |
.PHONY: clean | |
clean: | |
@echo "π§Ή Cleaning old build" | |
cd $(DESTDIR) && rm -rf * | |
.PHONY: get | |
get: | |
@echo "β Checking for hugo" | |
@if ! [ -x "$$(command -v hugo)" ]; then\ | |
echo "π€΅ Getting Hugo";\ | |
wget -q -P tmp/ https://github.com/gohugoio/hugo/releases/download/v$(HUGO_VERSION)/hugo_extended_$(HUGO_VERSION)_Linux-64bit.tar.gz;\ | |
tar xf tmp/hugo_extended_$(HUGO_VERSION)_Linux-64bit.tar.gz -C tmp/;\ | |
sudo mv -f tmp/hugo /usr/bin/;\ | |
rm -rf tmp/;\ | |
hugo version;\ | |
fi | |
.PHONY: build | |
build: | |
@echo "π³ Generating site" | |
hugo --gc --minify -d $(DESTDIR) | |
@echo "π§ Optimizing images" | |
$(OPTIMIZE) | |
.PHONY: test | |
test: | |
@echo "π Testing HTML" | |
docker run -v $(GITHUB_WORKSPACE)/$(DESTDIR)/:/mnt 18fgsa/html-proofer mnt --disable-external | |
.PHONY: deploy | |
deploy: | |
@echo "π Preparing commit" | |
@cd $(DESTDIR) \ | |
&& git config user.email "[email protected]" \ | |
&& git config user.name "Victoria via GitHub Actions" \ | |
&& git add . \ | |
&& git status \ | |
&& git commit -m "π€ CD bot is helping" \ | |
&& git push -f -q https://$(TOKEN)@github.com/victoriadrake/victoriadrake.github.io.git master | |
@echo "π Site is deployed!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment