Inital Commit
This commit is contained in:
parent
a742ad0ee2
commit
18a6f94117
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM debian:unstable-slim
|
||||
|
||||
RUN apt update
|
||||
RUN apt install curl -y
|
||||
COPY push.sh /bin/
|
||||
RUN chmod +x /bin/push.sh
|
||||
|
||||
ENTRYPOINT ["/bin/push.sh"]
|
42
README.md
42
README.md
@ -1,3 +1,43 @@
|
||||
# Woodpecker-Webdav
|
||||
|
||||
A Drone CI / Woodpecker CI plugin, that will allow pushing build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
A Drone CI / Woodpecker CI plugin, that will allow pushing build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
|
||||
## Settings
|
||||
|
||||
### Username
|
||||
|
||||
The username to the account that will be uploading to the WebDAV instance (if necessary)
|
||||
|
||||
### Password
|
||||
|
||||
The password to the account that will be uploading to the WebDAV instance (if necessary)
|
||||
|
||||
### proxy_url
|
||||
|
||||
May be used to specify a proxy (e.g. socks5://{ip_address}:{port}
|
||||
|
||||
### timeout
|
||||
|
||||
Defines a timeout (in seconds) to stop the upload after a certain time
|
||||
|
||||
### attempts
|
||||
|
||||
Defines how often a failed upload should be retried. Normally there is only one upload attempt
|
||||
|
||||
### destination
|
||||
|
||||
The WebDav folder url.
|
||||
|
||||
I.e `https://nextcloud.example.org/remote.php/dav/files/Admin/Folder/Fang/`
|
||||
|
||||
Note: The trailing slash is necessary.
|
||||
|
||||
### file_glob
|
||||
|
||||
The glob pattern for accessing the files that need to be uploaded. I.e `*-dist/*` will upload everything that mattches the glob pattern of `*-dist/*` in the current folder.
|
||||
|
||||
### make_folder_at
|
||||
|
||||
Directs the program to make a folder at a given webDAV location. Must use the same syntax as
|
||||
|
||||
I.e `https://nextcloud.example.org/remote.php/dav/files/Admin/Folder/Fang/GreenFang/`
|
||||
|
62
push.sh
Normal file
62
push.sh
Normal file
@ -0,0 +1,62 @@
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
ARGS=()
|
||||
|
||||
# Use WEBDAV_USERNAME as default, if provided.
|
||||
if [ -z "$PLUGIN_USERNAME" ] && [ -n "$WEBDAV_USERNAME" ]; then
|
||||
PLUGIN_USERNAME="$WEBDAV_USERNAME"
|
||||
fi
|
||||
|
||||
# Use WEBDAV_PASSWORD as default, if provided.
|
||||
if [ -z "$PLUGIN_PASSWORD" ] && [ -n "$WEBDAV_PASSWORD" ]; then
|
||||
PLUGIN_PASSWORD="$WEBDAV_PASSWORD"
|
||||
fi
|
||||
|
||||
# If username and password are provided, add auth
|
||||
if [ -n "$PLUGIN_USERNAME" ] && [ -n "$PLUGIN_PASSWORD" ]; then
|
||||
ARGS+=(--user "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}")
|
||||
fi
|
||||
|
||||
# Use a proxy, if one is specified
|
||||
if [ -n "$PLUGIN_PROXY_URL" ]; then
|
||||
ARGS+=(--proxy "${PLUGIN_PROXY_URL}")
|
||||
fi
|
||||
|
||||
# If a timeout is specified, make use of it.
|
||||
if [ -n "$PLUGIN_TIMEOUT" ]; then
|
||||
ARGS+=(--max-time "${PLUGIN_TIMEOUT}")
|
||||
fi
|
||||
|
||||
# Set PLUGIN_ATTEMPTS to one if nothing else is specified
|
||||
if [ -z "$PLUGIN_ATTEMPTS" ]; then
|
||||
PLUGIN_ATTEMPTS=1
|
||||
fi
|
||||
|
||||
#if [ -n "$PLUGIN_FILE_GLOB" ]; then
|
||||
# FILES={$(eval find "$PLUGIN_FILE_GLOB"|paste -s -d',')}
|
||||
# echo "$PLUGIN_FILE"
|
||||
#fi
|
||||
|
||||
if [ -n "$PLUGIN_MAKE_FOLDER_AT" ]; then
|
||||
curl --silent ${ARGS[@]} -X MKCOL "$PLUGIN_MAKE_FOLDER_AT"
|
||||
fi
|
||||
|
||||
# Repeat the upload as long as specified.
|
||||
while [ "${PLUGIN_ATTEMPTS}" -gt 0 ]; do
|
||||
|
||||
# Uploading the file
|
||||
for file in $(eval find "$PLUGIN_FILE_GLOB")
|
||||
do
|
||||
curl --fail-with-body --show-error --silent ${ARGS[@]} --upload-file "$file" "$PLUGIN_DESTINATION"
|
||||
done
|
||||
|
||||
# Show messages in case uploads have failed
|
||||
[ "$PLUGIN_ATTEMPTS" -gt 1 ] && {
|
||||
echo "[INFO] Upload failed. Attempting a new upload, if possible."
|
||||
}
|
||||
|
||||
sleep 5
|
||||
PLUGIN_ATTEMPTS=$((PLUGIN_ATTEMPTS-1))
|
||||
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user