Use Workdir-variable from arg

tool_auto-editor
Ruakij 2 years ago
parent b6c8457bc3
commit 85a3dbfb96

@ -4,9 +4,16 @@ scriptPath_file=$(dirname "${BASH_SOURCE[0]}")
scriptPath_folder=$(realpath "${scriptPath_file}") scriptPath_folder=$(realpath "${scriptPath_file}")
utils_path="${scriptPath_folder}/utils" utils_path="${scriptPath_folder}/utils"
WORKDIR=${1:-$PWD}
WORKDIR=$(realpath "$WORKDIR")
# Store original path
ORIGINALDIR=$PWD
# Get args without path # Get args without path
EXTRA_ARGS="${@:2}" EXTRA_ARGS="${@:2}"
# Call prepare # Call prepare
printf "# PREPARE\n" printf "# PREPARE\n"
source ${utils_path}/prepare.sh source ${utils_path}/prepare.sh
@ -15,3 +22,7 @@ source ${utils_path}/prepare.sh
printf "# BUILD\n" printf "# BUILD\n"
build_type=${BUILD:-"ownarch"} build_type=${BUILD:-"ownarch"}
source ${utils_path}/build-${build_type}.sh source ${utils_path}/build-${build_type}.sh
# Switch back to original path
cd $ORIGINALDIR

@ -7,4 +7,4 @@ docker buildx build \
--tag $TAG:latest \ --tag $TAG:latest \
--tag "${TAG}:${VERSION}" \ --tag "${TAG}:${VERSION}" \
$EXTRA_ARGS \ $EXTRA_ARGS \
. $WORKDIR

@ -5,4 +5,4 @@ docker build \
--tag $TAG:latest \ --tag $TAG:latest \
--tag $TAG:$VERSION \ --tag $TAG:$VERSION \
$EXTRA_ARGS \ $EXTRA_ARGS \
. "$WORKDIR"

@ -2,26 +2,32 @@
# --- VARIABLES --- # --- VARIABLES ---
# Load variables # Load variables
source $PWD/info.env source $WORKDIR/info.env
# Check if certain vars are overwritten, set them if missing # Check if certain vars are overwritten, set them if missing
if [ "${NAME}" = "" ]; then if [ "${NAME}" = "" ]; then
NAME="$(basename $PWD)" NAME="$(basename $WORKDIR)"
fi fi
export NAME export NAME
printf "Name: ${NAME}\n" printf "Name: ${NAME}\n"
repositoryFolder="$WORKDIR/.build/repository"
# --- SOURCES --- # --- SOURCES ---
alias git="git -C .build/repository"
# Get sources locally # Get sources locally
if ! [ -d .build/repository ]; then if ! [ -d "$repositoryFolder" ]; then
git clone "${GIT_REPOSITORY}" .build/repository git clone "${GIT_REPOSITORY}" .
else cloned=True
fi
# Change into repository
cd "$repositoryFolder"
if [ "$cloned" != True ]; then
# Checkout default-branch in case GIT_CHECKOUT was different # Checkout default-branch in case GIT_CHECKOUT was different
defaultBranch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') defaultBranch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
git checkout "${defaultBranch}" git checkout "${defaultBranch}"
git pull # Get changes git pull # Get changes
fi fi

Loading…
Cancel
Save