Skip to content

Instantly share code, notes, and snippets.

@victoriadrake
Created February 3, 2020 21:23
Show Gist options
  • Save victoriadrake/132f9aa40ce9ccee90aae62f27427332 to your computer and use it in GitHub Desktop.
Save victoriadrake/132f9aa40ce9ccee90aae62f27427332 to your computer and use it in GitHub Desktop.
.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