delete any existing packages
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is failing

This commit is contained in:
Simon Marsh 2023-11-30 14:33:23 +00:00
parent b4e8d88b7a
commit 20adfc8417
Signed by: burble
GPG Key ID: E9B4156C1659C079

View File

@ -11,14 +11,12 @@ then
fi
# other optional parameters
BASE_URL=${PLUGIN_URL:-https://git.burble.dn42/api/packages}
USER=${PLUGIN_USER:-burble}
OWNER=${PLUGIN_OWNER:-burble}
FILENAME=${PLUGIN_FILENAME:-$PLUGIN_ARTIFACT}
# version or token could be a filename
function maybe_from_file
{
local var="$1"
@ -34,12 +32,22 @@ VERSION=$(maybe_from_file "$PLUGIN_VERSION")
TOKEN=$(maybe_from_file "$PLUGIN_TOKEN")
##########################################################################
# finally do the curl thing to upload the artifact
# package URL
url=$(printf '%s/%s/generic/%s/%s/%s' \
"$BASE_URL" "$OWNER" "$PLUGIN_PACKAGE" \
"$VERSION" "$PLUGIN_ARTIFACT")
# check if there is already an existing package
status=$(curl --user "${USER}:${TOKEN}" -s -o /dev/null \
-w "%{http_code}" -X 'GET' "$url")
if [ "$status" -eq 200 ]
then
echo "Deleting existing package ..."
curl --user "${USER}:${TOKEN}" -X 'DELETE' "$url"
fi
# finally, actually upload the artifact
curl --user "${USER}:${TOKEN}" --upload-file "$FILENAME" "$url"
##########################################################################