~ajhalili2006's personal website, built with Zensical (successor of Material for Mkdocs) [old repo name got bugged while attempting to do manual knot migration via repo deletion] andreijiroh.dev
zensical mkdocs-material website
1#!/usr/bin/env bash 2set -ea 3if [[ $DEBUG != "" ]]; then 4 set -x 5fi 6 7## source vars from .env first ## 8_root_directory_git=$(git rev-parse --show-toplevel) 9# shellcheck file=/dev/null 10if [[ -f "$_root_directory_git/.env" ]]; then 11 source "$_root_directory_git/.env" 12fi 13 14_branch_name_git=$(git rev-parse --abbrev-ref HEAD) 15_commit_sha=$(git rev-parse HEAD) 16_commit_sha_short=$(git rev-parse --short HEAD) 17 18warn() { 19 echo "warning: $*" 20} 21 22error() { 23 echo "error: $*" 24} 25 26info() { 27 echo "info: $*" 28} 29 30if [[ $_branch_name_git == "main" ]] || [[ $_branch_name_git == "HEAD" ]]; then 31 export DEPLOY_COMMAND="npx wrangler pages deploy ${_root_directory_git}/public --project-name ${CF_PAGES_PROJECT_NAME} --branch main --commit-hash ${_commit_sha}" 32elif [[ $CI_PIPELINE_SOURCE == "merge_request" ]]; then 33 export DEPLOY_COMMAND="npx wrangler pages deploy ${_root_directory_git}/public --project-name ${CF_PAGES_PROJECT_NAME} --branch patch-$CI_MERGE_REQUEST_ID --commit-hash ${_commit_sha}" 34fi 35 36if ! git diff-index --quiet HEAD -- && [[ $FF_DIRTY_DEPLOY != "true" ]]; then 37 error Possible dirty working directory, aborting for safety reasons... 38 info To deploy while still dirty, set FF_DIRTY_DEPLOY=true on next invocation. 39 exit 1 40fi 41 42if [[ ! -d "$_root_directory_git/public" ]]; then 43 bash "$_root_directory_git/bin/build.sh" 44 cp markdown/.well-known public/ -rv 45fi 46 47if [[ $FF_DIRTY_DEPLOY == "true" ]]; then 48 $DEPLOY_COMMAND --commit-dirty=true 49else 50 DEFAULT_COMMAND="npx wrangler pages publish ${_root_directory_git}/public --project-name ${CF_PAGES_PROJECT_NAME} --branch main" 51 ${DEPLOY_COMMAND:-$DEFAULT_COMMAND} 52fi 53unset DEPLOY_COMMAND 54 55# temporarily disabled 56#if [[ $_branch_name_git == "main" ]] || [[ $_branch_name_git == "HEAD" ]]; then 57# tar -C public -cvz . -f site-build.tar.gz 58# curl --oauth2-bearer "$SOURCEHUT_PAGES_TOKEN" \ 59# -Fcontent=@site-build.tar.gz \ 60# "https://pages.sr.ht/publish/ajhalili2006.srht.site" 61#fi 62 63if [[ $DEBUG != "" ]]; then 64 set +x 65fi 66set +a