From a51fa7886887ab84d54231613efa45fc188a4e88 Mon Sep 17 00:00:00 2001 From: Michael de Wit Date: Thu, 29 Dec 2016 16:53:27 +0100 Subject: [PATCH] Add README and DOCS --- DOCS.md | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 26 ++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 DOCS.md diff --git a/DOCS.md b/DOCS.md new file mode 100644 index 0000000..64bb6b5 --- /dev/null +++ b/DOCS.md @@ -0,0 +1,61 @@ +Use the Rsync plugin to synchronize files to remote hosts, and execute arbitrary commands on those hosts. + +## Config +The following parameters are used to configure the plugin: +- **user** - user to log in as on the remote machines, defaults to `root` +- **key** - private SSH key for the remote machines +- **hosts** - hostnames or ip-addresses of the remote machines +- **port** - port to connect to on the remote machines, defaults to `22` +- **source** - source folder to synchronize from, defaults to `./` +- **target** - target folder on remote machines to synchronize to +- **include** - rsync include filter +- **exclude** - rsync exclude filter +- **recursive** - recursively synchronize, defaults to `false` +- **delete** - delete target folder contents, defaults to `false` +- **script** - list of commands to execute on remote machines + +The following secret values can be set to configure the plugin: +- **RSYNC_USER** - corresponds to **user** +- **RSYNC_KEY** - corresponds to **key** + +It is highly recommended to put the **RSYNC_KEY** into a secret so it is not exposed to users. This can be done using the drone-cli. + +```sh +drone secret add --image=drillster/drone-rsync \ + octocat/hello-world RSYNC_KEY @path/to/.ssh/id_rsa +``` + +Then sign the YAML file after all secrets are added. + +```sh +drone sign octocat/hello-world +``` + +See [secrets](http://readme.drone.io/0.5/usage/secrets/) for additional information on secrets. + +## Examples +```yaml +pipeline: + rsync: + image: drillster/drone-rsync + user: some-user + hosts: + - remote1 + - remote2 + source: ./dist + target: ~/packages + include: + - "app.tar.gz" + - "app.tar.gz.md5" + exclude: + - "**.*" + script: + - cd ~/packages + - md5sum -c app.tar.gz.md5 + - tar -xf app.tar.gz -C ~/app +``` + +The example above illustrates a situation where an app package (`app.tar.gz`) will be deployed to 2 remote hosts (`remote1` and `remote2`). An md5 checksum will be deployed as well. After deploying, the md5 checksum is used to check the deployed package. If successful the package is extracted. + +## Important +The script passed to **script** will be executed on remote machines directly after rsync completes to deploy the files. It will be executed step by step until a command returns a non-zero exit-code. If this happens, the entire plugin will exit and fail the build. diff --git a/README.md b/README.md index 69815e7..71d4030 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ # drone-rsync +[![drone-rsync on Docker Hub](https://img.shields.io/docker/automated/drillster/drone-rsync.svg)](https://hub.docker.com/r/drillster/drone-rsync/) + +This is a pure Bash [Drone](https://github.com/drone/drone) 0.5 plugin to sync files to remote hosts. + +For more information on how to use the plugin, please take a look at [the docs](https://github.com/Drillster/drone-rsync/blob/master/DOCS.md). + +## Docker +Build the docker image by running: + +```bash +docker build --rm=true -t drillster/drone-rsync . +``` + +## Usage +Execute from the working directory (assuming you have an SSH server running on 127.0.0.1:22): + +```bash +docker run --rm \ + -e PLUGIN_KEY=$(cat some-private-key) \ + -e PLUGIN_HOSTS="127.0.0.1" \ + -e PLUGIN_TARGET="./" \ + -e PLUGIN_SCRIPT="echo \"Done!\"" \ + -v $(pwd):$(pwd) \ + -w $(pwd) \ + drillster/drone-rsync +```