From b67b870e1dd4b21bfadca72985fafdfc69ba88e0 Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Tue, 8 Feb 2022 23:17:00 +0100 Subject: [PATCH] Better error handling. --- build.sh | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/build.sh b/build.sh index 1ff6939..7085dd8 100755 --- a/build.sh +++ b/build.sh @@ -1,29 +1,37 @@ #!/bin/bash +build() { + cd aleta + git fetch + current_commit=$(git rev-parse HEAD) + if [ $current_commit == `git rev-parse @{u}` ]; then + echo 'Aleta is updated' + cd - + return 1 + fi + git pull + cd - + if [ -e output ]; then + rm -rf output + fi + mkdir output + sudo docker build --no-cache -t aletareleaser:latest . + sudo docker run -v $(realpath output):/var/lib/aleta/output --rm aletareleaser +} source ~/.bashrc cd $(dirname $0) if [ -f aleta.lock ]; then echo 'Deploy is running.'; + exit 0; fi touch aleta.lock -pushd aleta -git fetch -current_commit=$(git rev-parse HEAD) -if [ $current_commit == `git rev-parse @{u}` ]; then - echo 'Aleta is updated' - exit 0 -fi -git pull -popd -if [ -e output ]; then - rm -rf output -fi -mkdir output -sudo docker build --no-cache -t aletareleaser:latest . -sudo docker run -v $(realpath output):/var/lib/aleta/output --rm -it aletareleaser -if [ ! -e output/aleta.tar.gz ]; then - echo "aleta.tar.gz not exists." 1>&2 - exit 1 -fi +build +exit_build=$? rm aleta.lock -perl create_aleta_release.pl +if [ $exit_build == 0 ]; then + if [ ! -e output/aleta.tar.gz ]; then + echo "aleta.tar.gz not exists." 1>&2 + exit 1 + fi + perl create_aleta_release.pl +fi