From 763af607c1d9a3958f7f3f3ccab6d8378df85921 Mon Sep 17 00:00:00 2001 From: Adam Veldhousen Date: Wed, 1 Jan 2020 18:28:55 -0600 Subject: [PATCH] added publish and local run commands --- assets/css/layout.scss | 1 + .../posts/git-tips-global-precommit-hook.md | 4 ++- makefile | 30 ++++++++++++++----- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/assets/css/layout.scss b/assets/css/layout.scss index cd34291..79a48dc 100644 --- a/assets/css/layout.scss +++ b/assets/css/layout.scss @@ -29,6 +29,7 @@ p { } #header { + margin-bottom: 20px; grid-column-start: 1; grid-column-end: 3; } diff --git a/content/posts/git-tips-global-precommit-hook.md b/content/posts/git-tips-global-precommit-hook.md index b58c1ce..a39f727 100755 --- a/content/posts/git-tips-global-precommit-hook.md +++ b/content/posts/git-tips-global-precommit-hook.md @@ -13,7 +13,7 @@ across your entire machine. ## Automatically lint and test on commit -One of my favorite hooks is a `~/.githooks/pre-commit` hook that auto runs test and lint commands from a `makefile` or +One of my favorite hooks is the `~/.githooks/pre-commit` hook that auto runs test and lint commands from a `makefile` or `package.json` if they're found: ```sh @@ -38,6 +38,8 @@ fi {{}} ``` +The `/usr/bin/env bash` piece ensures that the script has access to all of the environment variables you expect in your +regular shell. If the test or lint command fails then the `git commit` command fails. If I absolutely need to commit something in spite of the lint/test results I can do `git commit --no-verify` to skip the `pre-commit` hook. diff --git a/makefile b/makefile index 820d937..af5f8a9 100644 --- a/makefile +++ b/makefile @@ -1,17 +1,31 @@ -.PHONY: docker-build-dev serve write +VERSION := $(shell git rev-parse --abbrev-ref HEAD) +.PHONY: clean docker-build-dev serve write write: serve -new-post: - ./hugo new posts/$${TITLE:new_post}.md +build: public + docker build -t vdhsn/blog:${VERSION} -f Dockerfile . -hugo: - go get -u --tags extended -v github.com/gohugoio/hugo - go install --tags extended -v github.com/gohugoio/hugo +publish: build + docker push vdhsn/blog:${VERSION} + +test-publish: build + docker run -it -p 8080:80 vdhsn/blog:${VERSION} + +new-post: + @./hugo new posts/$${TITLE:new_post}.md docker-build-dev: - docker build --build-arg='VERSION=0.59.1' -t hugo -f Dockerfile.dev . + @docker build --build-arg='VERSION=0.59.1' -t hugo -f Dockerfile.dev . serve: - ./hugo server -D -w --bind 0.0.0.0 + ./hugo server -D --log -w --bind 0.0.0.0 + +clean: + @rm -rf ./public ./resources + +hugo: + @go get -u --tags extended -v github.com/gohugoio/hugo +public: + ./hugo --minify --gc