chore: Switch to just (#27)

Relates-to: [EM-1]
Reviewed-on: #27
Closes: #26
main
earnest ma 1 month ago
parent 27948c0e68
commit ef1707841a
Signed by: git.earne.link Git Service
GPG Key ID: 805C68AE8E896990
  1. 11
      .woodpecker.yml
  2. 43
      Justfile
  3. 49
      Makefile

@ -1,4 +1,5 @@
branches: main # Ideally, only run on pushes to main branch and PRs
---
branches: main # Ideally, only run on pushes to main branch and PRs
pipeline:
staging:
image: alpine:3
@ -6,7 +7,7 @@ pipeline:
event: [ pull_request ]
secrets: [ ssh_key ]
commands:
- apk add --no-cache git hugo make openssh-client rsync
- apk add --no-cache git hugo just openssh-client rsync
# lychee hasn't been packaged for Alpine Linux
- apk add --no-cache curl
- curl -LO https://github.com/lycheeverse/lychee/releases/download/v0.9.0/lychee-v0.9.0-x86_64-unknown-linux-musl.tar.gz
@ -15,7 +16,7 @@ pipeline:
- eval "$(ssh-agent -s)"
- echo "$SSH_KEY" | ssh-add -
- ./generatestageinfo.sh
- make deploy-staging
- just deploy-staging
main:
image: alpine:3
@ -24,7 +25,7 @@ pipeline:
branch: main
secrets: [ ssh_key ]
commands:
- apk add --no-cache git hugo make openssh-client rsync
- apk add --no-cache git hugo just openssh-client rsync
# lychee hasn't been packaged for Alpine Linux
- apk add --no-cache curl
- curl -LO https://github.com/lycheeverse/lychee/releases/download/v0.9.0/lychee-v0.9.0-x86_64-unknown-linux-musl.tar.gz
@ -32,4 +33,4 @@ pipeline:
- mkdir -p ~/.ssh && echo "StrictHostKeyChecking=no" >> ~/.ssh/config
- eval "$(ssh-agent -s)"
- echo "$SSH_KEY" | ssh-add -
- make all
- just deploy-main

@ -0,0 +1,43 @@
domain := "earnestma.com"
hugo_baseurl := "https://" + domain + "/"
staging_url := "https://staging.earnestma.com/"
staging_location := "earne@staging.earnestma.com:staging.earnestma.com"
user := "earne@" + domain
www_root := "/home/earne/" + domain
www_rsync_dest := user + ":" + www_root
output_dir := "public"
# build and deploy
default: deploy-main
# show this help (just --list)
help:
just --list
# remove output files
clean:
rm -rf {{ output_dir }}
rm -rf static/recipes.yaml
# build the site
build site=hugo_baseurl +flags='--gc': clean
cp data/recipes.yaml static/recipes.yaml
hugo -b {{ site }} {{ flags }}
# deploy
deploy-main: build
rsync {{ output_dir }}/ {{ www_rsync_dest }} -ravz --delete
# staging deploy
deploy-staging: (build staging_url)
rsync {{ output_dir }}/ {{ staging_location }} -ravz --delete
# serve
serve:
hugo serve
# run tests
test: build _test_check-links
_test_check-links:
lychee content/

@ -1,49 +0,0 @@
DOMAIN = earnestma.com
HUGO_BASEURL = https://$(DOMAIN)/
HUGO_FLAGS += --gc
USER = earne@$(DOMAIN)
WWW_ROOT = /home/earne/$(DOMAIN)
WWW_RSYNC_DEST = $(USER):$(WWW_ROOT)
OUTPUT_DIR = public
.PHONY: hugo
hugo: clean
cp data/recipes.yaml static/recipes.yaml
hugo -b $(HUGO_BASEURL) $(HUGO_FLAGS)
.PHONY: clean
clean: ## Remove temporary and build files
rm -rf $(OUTPUT_DIR)
rm -rf static/recipes.yaml
.PHONY: serve
serve: ## Start a development server, by default on localhost:1313
hugo serve
.PHONY: build
build: hugo
.PHONY: check-links
check-links: hugo
lychee content/
.PHONY: test
test: check-links ## Runs test, check links
.PHONY: deploy-main
deploy-main: build # test temporarily removed
rsync $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST)/ -ravz --delete
.PHONY: deploy-staging
deploy-staging: DOMAIN = staging.earnestma.com
deploy-staging: build test ## Build the website and deploy it to staging
rsync $(OUTPUT_DIR)/ $(WWW_RSYNC_DEST)/ -ravz --delete
.PHONY: help
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all: deploy-main ## Build the website and deploy it
Loading…
Cancel
Save