levineuwirth.org/Makefile

37 lines
1.0 KiB
Makefile

.PHONY: build deploy watch clean dev
# Source .env for GITHUB_TOKEN and GITHUB_REPO if it exists.
# .env format: KEY=value (one per line, no `export` prefix, no quotes needed).
-include .env
export
build:
@git add content/
@git diff --cached --quiet || git commit -m "auto: $$(date -u +%Y-%m-%dT%H:%M:%SZ)"
@date +%s > data/build-start.txt
cabal run site -- build
pagefind --site _site
> IGNORE.txt
@BUILD_END=$$(date +%s); \
BUILD_START=$$(cat data/build-start.txt); \
echo $$((BUILD_END - BUILD_START)) > data/last-build-seconds.txt
deploy: build
@if [ -z "$(GITHUB_TOKEN)" ] || [ -z "$(GITHUB_REPO)" ]; then \
echo "Skipping GitHub push: set GITHUB_TOKEN and GITHUB_REPO in .env"; \
else \
git push "https://$(GITHUB_TOKEN)@github.com/$(GITHUB_REPO).git" main; \
fi
rsync -avz --delete _site/ $(VPS_USER)@$(VPS_HOST):$(VPS_PATH)/
watch:
cabal run site -- watch
clean:
cabal run site -- clean
dev:
cabal run site -- clean
cabal run site -- build
python3 -m http.server 8000 --directory _site