From 15e3dedcee1d0830871ffc692143318a87646101 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Thu, 25 Jul 2024 02:12:22 +0200 Subject: wip --- .scripts.d/10-check.sh | 28 ++++++++++++++++++++++++++++ .scripts.d/20-build.sh | 21 +++++++++++++++++++++ .scripts.d/30-publish.sh | 21 +++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 .scripts.d/10-check.sh create mode 100644 .scripts.d/20-build.sh create mode 100644 .scripts.d/30-publish.sh (limited to '.scripts.d') diff --git a/.scripts.d/10-check.sh b/.scripts.d/10-check.sh new file mode 100644 index 0000000..a7c3b51 --- /dev/null +++ b/.scripts.d/10-check.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +docker run --rm \ + -v "$(pwd)":/site \ + -w /site \ + nixos/nix:2.21.4 \ + bash -c '\ + nix develop --extra-experimental-features "nix-command flakes" \ + -c bash -c "prettier --prose-wrap=always -c content/**/*.md" + ' + +echo "Ensure all posts are named with the date prefix" >&2 +find content/posts -type f -name "*.md" | while read -r f; do + if [[ ! "$f" =~ ^content/posts/[0-9]{4}-[0-9]{2}-[0-9]{2}-.*\.md$ ]]; then + echo "Filename $f does not match date pattern" + exit 1 + fi +done diff --git a/.scripts.d/20-build.sh b/.scripts.d/20-build.sh new file mode 100644 index 0000000..9a6350b --- /dev/null +++ b/.scripts.d/20-build.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +docker run --rm \ + -v "$(pwd)":/site \ + -w /site \ + nixos/nix:2.21.4 \ + bash -c '\ + nix build --extra-experimental-features "nix-command flakes" && \ + cp -R $(nix-store -qR result/) public + chmod -R 777 public + ' diff --git a/.scripts.d/30-publish.sh b/.scripts.d/30-publish.sh new file mode 100644 index 0000000..2bf49fa --- /dev/null +++ b/.scripts.d/30-publish.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# vim: ai:ts=8:sw=8:noet +set -EeufCo pipefail +export SHELLOPTS # propagate set to children by default +IFS=$'\t\n' + +# check required commands are in place +command -v docker >/dev/null 2>&1 || { + echo 'please install docker-client' + exit 1 +} + +docker run --rm \ + -v "$(pwd)/public":/public \ + -w /public \ + -e CLOUDFLARE_API_TOKEN="${CLOUDFLARE_API_TOKEN}" \ + node:lts-slim \ + bash -c '\ + npm install -g wrangler && \ + wrangler pages deploy . --project-name check-caps-lock + ' -- cgit v1.2.3