mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 02:11:36 +00:00
update docker publish script
This commit is contained in:
parent
7cda14cb76
commit
f54c754971
@ -1,21 +1,54 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
TAG=$1
|
BRANCH=""
|
||||||
|
TAGS=()
|
||||||
|
|
||||||
if [ -z "$TAG" ]; then
|
# Parse arguments
|
||||||
echo "No tag provided"
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--branch)
|
||||||
|
BRANCH="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--tags)
|
||||||
|
IFS=',' read -r -a TAGS <<< "$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Validate inputs
|
||||||
|
if [ -z "$BRANCH" ]; then
|
||||||
|
echo "No branch provided. Use --branch <git_branch>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ${#TAGS[@]} -eq 0 ]; then
|
||||||
|
echo "No tags provided. Use --tags tag1,tag2,tag3"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clone the specified branch of the repo
|
||||||
rm -rf /tmp/vito
|
rm -rf /tmp/vito
|
||||||
|
git clone --branch "$BRANCH" --depth 1 git@github.com:vitodeploy/vito.git /tmp/vito
|
||||||
git clone git@github.com:vitodeploy/vito.git /tmp/vito
|
|
||||||
|
|
||||||
cd /tmp/vito || exit
|
cd /tmp/vito || exit
|
||||||
|
|
||||||
|
# Prepare tag arguments for docker buildx
|
||||||
|
TAG_ARGS=()
|
||||||
|
for TAG in "${TAGS[@]}"; do
|
||||||
|
# Trim whitespace to avoid invalid tag formatting
|
||||||
|
TAG_CLEANED=$(echo -n "$TAG" | xargs)
|
||||||
|
TAG_ARGS+=("-t" "vitodeploy/vito:$TAG_CLEANED")
|
||||||
|
done
|
||||||
|
|
||||||
|
# Build and push the image
|
||||||
docker buildx build . \
|
docker buildx build . \
|
||||||
-f docker/Dockerfile \
|
-f docker/Dockerfile \
|
||||||
-t vitodeploy/vito:"$TAG" \
|
"${TAG_ARGS[@]}" \
|
||||||
--platform linux/amd64,linux/arm64 \
|
--platform linux/amd64,linux/arm64 \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
--push
|
--push
|
||||||
|
Loading…
x
Reference in New Issue
Block a user