Use Workdir-variable from arg

This commit is contained in:
2022-11-23 18:38:52 +01:00
parent b6c8457bc3
commit 85a3dbfb96
4 changed files with 26 additions and 9 deletions

View File

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

View File

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

View File

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