feat(gitea-download): allow anonymous download
This commit is contained in:
parent
3bf8e64888
commit
2c182df6a6
|
@ -5,6 +5,7 @@ set -eo pipefail
|
|||
GITEA_DOWNLOAD_PROJECT=${GITEA_DOWNLOAD_PROJECT}
|
||||
GITEA_DOWNLOAD_ORG=${GITEA_DOWNLOAD_ORG}
|
||||
GITEA_DOWNLOAD_BASE_URL=${GITEA_BASE_URL:-https://forge.cadoles.com}
|
||||
GITEA_DOWNLOAD_ANONYMOUS=${GITEA_DOWNLOAD_ANONYMOUS:-no}
|
||||
GITEA_DOWNLOAD_USERNAME=${GITEA_DOWNLOAD_USERNAME}
|
||||
GITEA_DOWNLOAD_PASSWORD=${GITEA_DOWNLOAD_PASSWORD}
|
||||
GITEA_DOWNLOAD_RELEASE_NAME=${GITEA_DOWNLOAD_RELEASE_NAME:-latest}
|
||||
|
@ -52,6 +53,10 @@ function assert_environment {
|
|||
}
|
||||
|
||||
function ask_credentials {
|
||||
if [ "${GITEA_DOWNLOAD_ANONYMOUS}" == "yes" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -z "$GITEA_DOWNLOAD_USERNAME" ]; then
|
||||
echo -n "Username: "
|
||||
read GITEA_DOWNLOAD_USERNAME
|
||||
|
@ -104,11 +109,14 @@ function gitea_api {
|
|||
local path=$1
|
||||
local args=${@:2}
|
||||
|
||||
if [ "${GITEA_DOWNLOAD_ANONYMOUS}" != 'yes' ]; then
|
||||
args="-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" ${args}"
|
||||
fi
|
||||
|
||||
curl -L \
|
||||
--fail \
|
||||
--ipv4 \
|
||||
-k \
|
||||
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
||||
${args} \
|
||||
"$GITEA_DOWNLOAD_BASE_URL/api/v1$path"
|
||||
}
|
||||
|
@ -117,11 +125,14 @@ function gitea_download {
|
|||
local attachment_id=$1
|
||||
local output=$2
|
||||
|
||||
if [ "${GITEA_DOWNLOAD_ANONYMOUS}" != 'yes' ]; then
|
||||
GITEA_DOWNLOAD_CURL_ARGS="-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" ${GITEA_DOWNLOAD_CURL_ARGS}"
|
||||
fi
|
||||
|
||||
curl -L \
|
||||
--fail \
|
||||
--ipv4 \
|
||||
-k \
|
||||
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
||||
--output "$output" \
|
||||
$GITEA_DOWNLOAD_CURL_ARGS \
|
||||
"$GITEA_DOWNLOAD_BASE_URL/attachments/$attachment_id"
|
||||
|
|
Loading…
Reference in New Issue