git-build.sh first edition

This commit is contained in:
southerntofu 2020-04-17 21:59:19 -04:00
parent 7ff46b7f85
commit 7486e872d7
6 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1 @@
thunix.net

19
.git-build/rfc Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
[[ $# = 0 ]] && echo "ERROR" && exit 1
ARGS=""
if [ -f $GITBUILDDIR/config/hostname ]; then
base_url="https://$(cat $GITBUILDDIR/config/hostname)/~$USER/$1"
echo $base_url
ARGS="$ARGS -u $base_url"
fi
zola build $ARGS
if [[ $? != 0 ]]; then
echo "Building site $1 failed."
exit 2
fi
rm -R ~/public_html/$1
cp -R public ~/public_html/$1
rm -R public

1
.git-build/rfc.branch Normal file
View File

@ -0,0 +1 @@
drafts

1
.git-build/rfc.source Normal file
View File

@ -0,0 +1 @@
https://tildegit.org/southerntofu/rfcs

View File

@ -1,3 +1,22 @@
# git-build.sh
Lightweight, KISS system to rebuild some git projects when they change.
Lightweight, KISS system to rebuild some git projects when they change.
# Setup
Simply place git-build.sh in your path.
# Usage
git-build.sh looks up your ~/.git-build/ folder to find stuff to build:
- config/ <-- additional settings/files for use in scripts
- PROJECT.source <-- URL to the git repo for PROJECT
- PROJECT.branch (optional) <-- branch to checkout
- PROJECT <-- script to execute when the project is updated
Additionally, for each PROJECT a .PROJECT/ folder is created to clone the repository.
# Example
As an example on how to get started, this repo includes a .git-build/ folder. It's the configuration that generates [this site](https://thunix.net/~southerntofu/rfc).

21
git-build.sh Executable file
View File

@ -0,0 +1,21 @@
#/bin/bash
BASEDIR="$HOME/.git-build"
for project in $BASEDIR/*.source; do
p_name="$(basename $project .source)"
p_dir="$BASEDIR/.$p_name"
if [ ! -d $p_dir ]; then
git clone "$(cat $BASEDIR/$p_name.source)" "$p_dir"
if [ -f $BASEDIR/$p_name.branch ]; then
cd $p_dir
git checkout "$(cat $BASEDIR/$p_name.branch)"
fi
fi
if [ ! -d $p_dir ]; then
echo "ERROR: could not create repo for project $project"
exit 1
fi
cd "$p_dir"
GITBUILDDIR="$BASEDIR" eval "$BASEDIR/$p_name $p_name"
done