Deploying an ISO to Nextcloud

I recently wrote an article on building a custom ArchLinux-based live distro with Drone. This setup has worked quite well for me, and it saved me a lot of time in the long run. There’s just one thing that bothers me about it: after it is built, the ISO is copied to an open directory. I can then download the ISO from there and flash it onto a USB. I wanted to make sure that the ISO is actually “deployed” on all of my devices after it’s built, so I don’t have to download it manually. This also removes the possibility of there being multiple versions on multiple machines, and saves me the hassle of always having to remember to download it.

I decided the best way of doing this would be via NextCloud. I have a NextCloud server, which syncs important files between my devices. This would be the perfect tool for “deploying” the new ISO to all of the devices that it is needed on.

Nextcloud has an API for their WebDAV implementation. This allows us to use WebDav operations to download, upload, and change files on the server. This is pretty much ideal for our use case. Since WebDAV is an extension of HTTP, I can use my favourite API client (curl + bash).

#!/usr/bin/env bash

curl -u "${USERNAME}:${PASSWORD}" \"$FILE" \
    -T "$BUILD_DIR/out/$FILE"

Our client will need a password. To provide this, we can create an Application Password in NextCloud. After generating it, we will use Drone to provide the password to our script. We don’t want to store our password in plain text, so we can use drones secret management. Secrets are defined per repository under settings -> secrets. After adding our secret, we can use it in our pipeline.

kind: pipeline
type: exec
name: default

- name: upload iso to nextcloud
    - ./extra/upload/
    BUILD_DIR: /media/fast/cryptset/builds/spart
        from_secret: nc_password

  - main

Drone continues to be a very useful tool, and I look forward to doing more stuff with it. I hope you enjoyed reading this article!

Articles from blogs I read - Generated by openring