From 281157346eaa33a1ea8397f725ba9148c1dc3887 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 11 Dec 2021 17:35:21 +0100 Subject: [PATCH] Add option to build for staging This uses a different base url and adds uses an all-blocking robots.txt. --- build.sh | 20 +++++++++++++++++--- flake.nix | 7 ++++++- static/{robots.txt => robots.txt.staging} | 0 3 files changed, 23 insertions(+), 4 deletions(-) rename static/{robots.txt => robots.txt.staging} (100%) diff --git a/build.sh b/build.sh index da15ca1..267ce8b 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +1,22 @@ -#!/bin/sh +#!/usr/bin/env bash set -e + +declare -a zola_options + +SCHABERNACK_ENV=${SCHABERNACK_ENV:-production} + +if [ "${SCHABERNACK_ENV}" = "staging" ]; then + echo "Building staging version" >&2 + zola_options+=(-u https://staging.schulischer-schabernack.de) +fi + ./metadata.py -zola build +zola build ${zola_options[@]} echo "Encoding…" ./encode.py ./metadata.py -zola build +zola build ${zola_options[@]} + +if [ "${SCHABERNACK_ENV}" = "staging" ]; then + cp static/robots.txt.staging public/robots.txt +fi diff --git a/flake.nix b/flake.nix index 8d3e239..2aac8ea 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; in rec { - packages = { + packages = rec { bulma = pkgs.fetchzip { url = "https://github.com/jgthms/bulma/releases/download/0.9.0/bulma-0.9.0.zip"; sha256 = "sha256-FKWdkq6pRukCzR2IQ88OHlPkIJbeeEz7NdIWv44k8TM="; @@ -32,6 +32,7 @@ , ffmpeg-full , python3 , zola + , staging ? false }: let linkVendor = '' @@ -56,6 +57,8 @@ zola ]; + SCHABERNACK_ENV = if staging then "staging" else "production"; + postPatch = '' patchShebangs . ''; @@ -85,6 +88,8 @@ ''; }) { }; + + schulischer-schabernack-staging = schulischer-schabernack.override { staging = true; }; }; defaultPackage = packages.schulischer-schabernack; diff --git a/static/robots.txt b/static/robots.txt.staging similarity index 100% rename from static/robots.txt rename to static/robots.txt.staging