feat(gitea,download): allow attachments filtering with regex
This commit is contained in:
parent
199b0bf5d1
commit
21c7fb0e61
|
@ -9,6 +9,7 @@ GITEA_DOWNLOAD_USERNAME=${GITEA_DOWNLOAD_USERNAME}
|
||||||
GITEA_DOWNLOAD_PASSWORD=${GITEA_DOWNLOAD_PASSWORD}
|
GITEA_DOWNLOAD_PASSWORD=${GITEA_DOWNLOAD_PASSWORD}
|
||||||
GITEA_DOWNLOAD_RELEASE_NAME=${GITEA_DOWNLOAD_RELEASE_NAME:-latest}
|
GITEA_DOWNLOAD_RELEASE_NAME=${GITEA_DOWNLOAD_RELEASE_NAME:-latest}
|
||||||
GITEA_DOWNLOAD_TARGET_DIRECTORY=${GITEA_DOWNLOAD_TARGET_DIRECTORY:-gitea-dl}
|
GITEA_DOWNLOAD_TARGET_DIRECTORY=${GITEA_DOWNLOAD_TARGET_DIRECTORY:-gitea-dl}
|
||||||
|
GITEA_DOWNLOAD_ATTACHMENTS_FILTER="${GITEA_DOWNLOAD_ATTACHMENTS_FILTER:-.*}"
|
||||||
|
|
||||||
function check_dependencies {
|
function check_dependencies {
|
||||||
assert_command_available 'curl'
|
assert_command_available 'curl'
|
||||||
|
@ -106,6 +107,7 @@ function gitea_api {
|
||||||
curl -L \
|
curl -L \
|
||||||
--fail \
|
--fail \
|
||||||
--ipv4 \
|
--ipv4 \
|
||||||
|
-k \
|
||||||
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
||||||
${args} \
|
${args} \
|
||||||
"$GITEA_DOWNLOAD_BASE_URL/api/v1$path"
|
"$GITEA_DOWNLOAD_BASE_URL/api/v1$path"
|
||||||
|
@ -120,6 +122,7 @@ function gitea_download {
|
||||||
--ipv4 \
|
--ipv4 \
|
||||||
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
-u "$GITEA_DOWNLOAD_USERNAME:$GITEA_DOWNLOAD_PASSWORD" \
|
||||||
--output "$output" \
|
--output "$output" \
|
||||||
|
$GITEA_DOWNLOAD_CURL_ARGS \
|
||||||
"$GITEA_DOWNLOAD_BASE_URL/attachments/$attachment_id"
|
"$GITEA_DOWNLOAD_BASE_URL/attachments/$attachment_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,10 +144,15 @@ function download_release_files {
|
||||||
mkdir -p "$GITEA_DOWNLOAD_TARGET_DIRECTORY"
|
mkdir -p "$GITEA_DOWNLOAD_TARGET_DIRECTORY"
|
||||||
|
|
||||||
local attachment_uuids=$(echo $assets | jq -r '.[].uuid')
|
local attachment_uuids=$(echo $assets | jq -r '.[].uuid')
|
||||||
|
|
||||||
for uuid in $attachment_uuids; do
|
for uuid in $attachment_uuids; do
|
||||||
local filename=$(echo $assets | jq -r --arg uuid "$uuid" '. | map(select( .uuid == $uuid)) | .[0].name')
|
local filename=$(echo $assets | jq -r --arg uuid "$uuid" '. | map(select( .uuid == $uuid)) | .[0].name')
|
||||||
gitea_download "$uuid" "$GITEA_DOWNLOAD_TARGET_DIRECTORY/$filename"
|
|
||||||
|
if [[ "$filename" =~ $GITEA_DOWNLOAD_ATTACHMENTS_FILTER ]]; then
|
||||||
|
echo "Downloading attachment '$filename'"
|
||||||
|
gitea_download "$uuid" "$GITEA_DOWNLOAD_TARGET_DIRECTORY/$filename"
|
||||||
|
else
|
||||||
|
echo "Ignoring attachment '$filename'"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue