Skip to content

Instantly share code, notes, and snippets.

@peter-dolkens
Last active February 17, 2020 03:05
Show Gist options
  • Save peter-dolkens/4b89c5a732ef1ea4fcb714252037e4ba to your computer and use it in GitHub Desktop.
Save peter-dolkens/4b89c5a732ef1ea4fcb714252037e4ba to your computer and use it in GitHub Desktop.
Sample Makefile - Jekyll Blog
SHELL := /usr/bin/env bash
.PHONY : all
###############################################################################
# HELP
###############################################################################
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
TARGET_MAX_CHAR_NUM=20
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' make ${YELLOW}<target>${RESET} ${GREEN}<description>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Debug the Jeckyll build
debug:
MSYS_NO_PATHCONV=1 \
MSYS2_ARG_CONV_EXC="*" \
docker run -it \
-v $(shell pwd)/src:/srv/jekyll \
--rm jekyll/builder:3.8 \
bash
## Build the Jeckyll site
build:
MSYS_NO_PATHCONV=1 \
MSYS2_ARG_CONV_EXC="*" \
docker run \
-v $(shell pwd)/src:/srv/jekyll \
--rm jekyll/builder:3.8 \
/bin/bash -c "chmod 777 /srv/jekyll && jekyll build"
## Run the Jeckyll site
run:
MSYS_NO_PATHCONV=1 \
MSYS2_ARG_CONV_EXC="*" \
docker run -it -p 4000:4000 \
-v $(shell pwd)/src:/srv/jekyll \
--env JEKYLL_ENV=production \
--rm jekyll/jekyll:3.8 \
jekyll serve --watch --config _config.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment