Sebastian Mark
41d3d04fe7
- add support for passing stacklist as cli parameters
- refactor iteration over stacklist entries
- improve comments for better code understanding
- update README.md
🤖
44 lines
987 B
Bash
Executable file
44 lines
987 B
Bash
Executable file
#! /bin/bash
|
|
|
|
## Author: Sebastian Mark
|
|
## CC-BY-SA (https://creativecommons.org/licenses/by-sa/4.0/deed.de)
|
|
## for civil use only
|
|
|
|
## see README.md
|
|
|
|
h1() { echo "* $*"; }
|
|
msg() { echo "$*"; }
|
|
|
|
BASEDIR=$(dirname $0)
|
|
|
|
# use list from file or passed parameters
|
|
STACKLIST=$(cat $BASEDIR/stacklist)
|
|
[[ $# -gt 0 ]] && STACKLIST=$*
|
|
|
|
# iterate list
|
|
for LINE in $STACKLIST; do
|
|
grep -q "^[[:space:]]*#" <<<$LINE && continue # skip comments
|
|
|
|
# determine if passed a directory or a file
|
|
STACKDIR=$LINE
|
|
if [[ -f $LINE ]]; then
|
|
STACKDIR=$(dirname $LINE)
|
|
COMPOSEFILE=$LINE
|
|
fi
|
|
|
|
h1 "processing $STACKDIR"
|
|
|
|
# skip if directroy not found
|
|
cd $STACKDIR || continue
|
|
|
|
# fetch from repo and check for new commits
|
|
git fetch --quiet
|
|
if [[ $(git rev-parse HEAD) == $(git rev-parse "@{u}") ]]; then
|
|
msg "no changes - skipping"
|
|
continue
|
|
fi
|
|
|
|
# pull new commits and run docker compose
|
|
git pull
|
|
docker compose --file ${COMPOSEFILE:=docker-compose.yml} up --build --detach --remove-orphans
|
|
done
|