mirror of
https://github.com/ViViDboarder/drone-webdav.git
synced 2024-06-02 15:32:24 +00:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2d66c38714 | ||
|
9693473c95 | ||
|
133bfd843d | ||
|
c61ba9725f | ||
|
e1aadcea34 | ||
|
48079a250f | ||
|
71e9fdd0f3 | ||
|
95b0ef6abf | ||
|
5d84b40f1c | ||
|
b7a984ed39 | ||
|
d9d0424b9f | ||
|
5f3f05247a | ||
|
06beaed6ab | ||
|
73ee27f14e | ||
|
66ac1fa9a7 | ||
|
051ccd20e3 | ||
|
9fc797e244 | ||
|
30acb3ee44 | ||
|
95baa0b710 | ||
|
d88042153f | ||
|
6dd4d6a367 | ||
|
6d0e68aeea | ||
|
eaf8993535 | ||
|
55ea8f5fe7 | ||
|
7b236ca078 | ||
|
30febb63a3 |
104
.github/workflows/docker-publish.yml
vendored
Normal file
104
.github/workflows/docker-publish.yml
vendored
Normal file
|
@ -0,0 +1,104 @@
|
|||
name: Docker
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: docker.io
|
||||
REGISTRY_USERNAME: vividboarder
|
||||
# github.repository as <account>/<repo>
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
PLATFORMS: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/ppc64le,linux/s390x
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Install the cosign tool except on PR
|
||||
# https://github.com/sigstore/cosign-installer
|
||||
- name: Install cosign
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06
|
||||
with:
|
||||
cosign-release: 'v2.1.1'
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
|
||||
|
||||
- name: Available platforms
|
||||
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ env.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4.0.1
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
tags: |
|
||||
# Tag default branch as latest
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
# Semver tags for tagged versions
|
||||
type=semver,pattern={{version}}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
|
||||
# Sign the resulting Docker image digest except on PRs.
|
||||
# This will only write to the public Rekor transparency log when the Docker
|
||||
# repository is public to avoid leaking data. If you would like to publish
|
||||
# transparency data even for private images, pass --force to cosign below.
|
||||
# https://github.com/sigstore/cosign
|
||||
- name: Sign the published Docker image
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
env:
|
||||
COSIGN_EXPERIMENTAL: "true"
|
||||
# This step uses the identity token to provision an ephemeral certificate
|
||||
# against the sigstore community Fulcio instance.
|
||||
run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --yes {}@${{ steps.build-and-push.outputs.digest }}
|
|
@ -1,6 +1,6 @@
|
|||
FROM alpine:3.11
|
||||
FROM alpine:3.17
|
||||
|
||||
RUN apk --no-cache add bash=~5.0 curl=~7.67 ca-certificates=~20191127
|
||||
RUN apk --no-cache add bash=~5 curl=~8 ca-certificates=~20230506
|
||||
COPY push.sh /bin/
|
||||
RUN chmod +x /bin/push.sh
|
||||
|
||||
|
|
7
Makefile
7
Makefile
|
@ -1,10 +1,10 @@
|
|||
.PHONY: clean all
|
||||
.PHONY: clean
|
||||
|
||||
.PHONY: default
|
||||
default: test
|
||||
|
||||
.PHONY: test
|
||||
test: check
|
||||
test:
|
||||
docker-compose -f ./tests/docker-compose-private.yml up \
|
||||
--build --force-recreate \
|
||||
--abort-on-container-exit --exit-code-from plugin
|
||||
|
@ -18,3 +18,6 @@ install-hooks:
|
|||
.PHONY: check
|
||||
check:
|
||||
pre-commit run --all-files
|
||||
|
||||
.PHONY: all
|
||||
all: test check
|
||||
|
|
38
Readme.md
38
Readme.md
|
@ -1,5 +1,6 @@
|
|||
# drone-webdav
|
||||
A WebDAV plugin, for the drone.io project, which allows you to push build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
|
||||
A [Drone CI](https://www.drone.io/) / [Woodpecker CI](https://woodpecker-ci.org/) plugin, that will allow pushing build artifacts to any WebDAV server, including Nextcloud or ownCloud.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -9,10 +10,11 @@ An example configuration would be as follows:
|
|||
pipeline:
|
||||
upload_debug:
|
||||
image: vividboarder/drone-webdav
|
||||
file: com.vividboarder.otbeta/build/outputs/apk/com.vividboarder.otbeta-debug.apk
|
||||
destination: https://my.nextcloud.com/remote.php/dav/files/vividboarder/Android/Apks/
|
||||
user: myusername
|
||||
password: mypassword
|
||||
settings:
|
||||
file: com.vividboarder.otbeta/build/outputs/apk/com.vividboarder.otbeta-debug.apk
|
||||
destination: https://my.nextcloud.com/remote.php/dav/files/vividboarder/Android/Apks/
|
||||
username: myusername
|
||||
password: mypassword
|
||||
```
|
||||
|
||||
You probably don't want to check your credentials into your repo, so you may use secrets for this:
|
||||
|
@ -21,20 +23,21 @@ You probably don't want to check your credentials into your repo, so you may use
|
|||
pipeline:
|
||||
upload_debug:
|
||||
image: vividboarder/drone-webdav
|
||||
file: com.vividboarder.otbeta/build/outputs/apk/com.vividboarder.otbeta-debug.apk
|
||||
destination: https://my.nextcloud.com/remote.php/dav/files/vividboarder/Android/Apks/
|
||||
secrets:
|
||||
- source: WEBDAV_USER
|
||||
target: PLUGIN_USERNAME
|
||||
- source: WEBDAV_PASSWORD
|
||||
target: PLUGIN_PASSWORD
|
||||
settings:
|
||||
file: com.vividboarder.otbeta/build/outputs/apk/com.vividboarder.otbeta-debug.apk
|
||||
destination: https://my.nextcloud.com/remote.php/dav/files/vividboarder/Android/Apks/
|
||||
username:
|
||||
from_secret: WEBDAV_USER
|
||||
password:
|
||||
from_secret: WEBDAV_PASSWORD
|
||||
```
|
||||
|
||||
## FAQ
|
||||
|
||||
#### How do I upload multiple files at once?
|
||||
Since this script uses **curl** to upload your files, you can use it's corresponding syntax.<br>
|
||||
An example, taken from the official [documentation](https://curl.haxx.se/docs/manpage.html#-T), would be to pass ``{dogs.png,cats.jpg}`` to ``PLUGIN_FILE``.
|
||||
### How do I upload multiple files at once?
|
||||
|
||||
Since this script uses **curl** to upload your files, you can use it's corresponding syntax.
|
||||
An example, taken from the official [documentation](https://curl.se/docs/manpage.html#-T), would be to pass ``{dogs.png,cats.jpg}`` to ``PLUGIN_FILE``.
|
||||
|
||||
## Customization
|
||||
|
||||
|
@ -47,11 +50,12 @@ The following environment variables can be used for further cutomization:
|
|||
| ``PLUGIN_ATTEMPTS`` | Defines how often a failed upload should be retried. Normally there is only one upload attempt. |
|
||||
| ``PLUGIN_CUSTOM_ARGUMENTS`` | Additional arguments to be passed to `curl`. |
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
There are only two tests right now and they are configured using Docker Compose. To run them, just use
|
||||
|
||||
make test
|
||||
```sh
|
||||
make test
|
||||
```
|
||||
|
||||
If someone wants to make this better (or add a Drone file) I'd gladly accept the patch.
|
||||
|
|
46
docs.md
Normal file
46
docs.md
Normal file
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
name: WebDAV
|
||||
description: plugin to publish any artifacts to any WebDAV server
|
||||
author: vividboarder
|
||||
tags: [deploy, publish]
|
||||
containerImage: vividboarder/drone-webdav
|
||||
containerImageUrl: https://hub.docker.com/r/vividboarder/drone-webdav
|
||||
url: https://github.com/vividboarder/drone-webdav
|
||||
---
|
||||
|
||||
A [Drone CI](https://www.drone.io/) / [Woodpecker CI](https://woodpecker-ci.org/) plugin,
|
||||
that will allow pushing build artifacts to any [WebDAV](http://www.webdav.org/) server, including Nextcloud or ownCloud.
|
||||
|
||||
## Features
|
||||
|
||||
- Upload multiple files
|
||||
- Use a proxy
|
||||
- Retry on fail
|
||||
|
||||
## Settings
|
||||
|
||||
| Settings Name | Required | Description
|
||||
| ------------------ |--------- | --------------------------------------------
|
||||
| `file` | **✓** | File(s) to upload. Use [curl syntax](https://curl.se/docs/manpage.html#-T) for multiple (e.g. `{dogs.png,cats.jpg}`)
|
||||
| `destination` | **✓** | The WebDav **folder** url
|
||||
| `username` | **✓** | The WebDav-**User** to use
|
||||
| `password` | | The **Password** for the WebDav-User
|
||||
| `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
|
||||
| `custom_arguments` | | Additional arguments to be passed to [`curl`](https://curl.se/)
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
pipeline:
|
||||
upload_debug:
|
||||
image: vividboarder/drone-webdav
|
||||
settings:
|
||||
file: com.vividboarder.otbeta/build/outputs/apk/com.vividboarder.otbeta-debug.apk
|
||||
destination: https://my.nextcloud.com/remote.php/dav/files/vividboarder/Android/Apks/
|
||||
username:
|
||||
from_secret: WEBDAV_USER
|
||||
password:
|
||||
from_secret: WEBDAV_PASSWORD
|
||||
```
|
12
push.sh
12
push.sh
|
@ -36,8 +36,16 @@ fi
|
|||
# Repeat the upload as long as specified.
|
||||
while [ "${PLUGIN_ATTEMPTS}" -gt 0 ]; do
|
||||
|
||||
# Uploading the file
|
||||
curl "${ARGS[@]}" --upload-file "$PLUGIN_FILE" "$PLUGIN_DESTINATION" && {
|
||||
# Uploading the file
|
||||
# shellcheck disable=SC2086
|
||||
curl \
|
||||
$PLUGIN_CUSTOM_ARGUMENTS \
|
||||
--fail-with-body \
|
||||
--show-error \
|
||||
--silent \
|
||||
"${ARGS[@]}" \
|
||||
--upload-file "$PLUGIN_FILE" \
|
||||
"$PLUGIN_DESTINATION" && {
|
||||
# Terminate the script as soon as the upload is successful
|
||||
echo "[INFO] Upload was successful."
|
||||
exit 0
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
version: '2.4'
|
||||
version: '3'
|
||||
services:
|
||||
webdav:
|
||||
image: sashgorokhov/webdav
|
||||
image: bytemark/webdav
|
||||
environment:
|
||||
USERNAME: jdoe
|
||||
PASSWORD: hunter2
|
||||
|
@ -12,9 +12,9 @@ services:
|
|||
context: ../
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- './test.txt:/test.txt'
|
||||
- '.:/test'
|
||||
environment:
|
||||
PLUGIN_FILE: '/test.txt'
|
||||
PLUGIN_FILE: '/test/test{1,2}.txt'
|
||||
PLUGIN_DESTINATION: 'http://webdav/'
|
||||
PLUGIN_USERNAME: jdoe
|
||||
PLUGIN_PASSWORD: hunter2
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
---
|
||||
version: '2.4'
|
||||
version: '3'
|
||||
services:
|
||||
webdav:
|
||||
image: sashgorokhov/webdav
|
||||
image: bytemark/webdav
|
||||
environment:
|
||||
ANONYMOUS_METHODS: ALL
|
||||
|
||||
plugin:
|
||||
build:
|
||||
context: ../
|
||||
dockerfile: Dockerfile
|
||||
volumes:
|
||||
- './test.txt:/test.txt'
|
||||
- '.:/test'
|
||||
environment:
|
||||
PLUGIN_FILE: '/test.txt'
|
||||
PLUGIN_FILE: '/test/test{1,2}.txt'
|
||||
PLUGIN_DESTINATION: 'http://webdav/'
|
||||
PLUGIN_TIMEOUT: 10
|
||||
PLUGIN_ATTEMPTS: 4
|
||||
|
|
1
tests/test2.txt
Normal file
1
tests/test2.txt
Normal file
|
@ -0,0 +1 @@
|
|||
ohai
|
Loading…
Reference in New Issue
Block a user