Skip to content

Commit

Permalink
✨ Add (s)ftp, git and cloud (via rclone) exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen-lbh committed Apr 14, 2024
1 parent 342b78d commit 3e07247
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- (S)FTP exporter
- Git exporter: clones a repo, adds and commits the database json file and pushes
- Cloud exporter: uses rclone to upload the database.json file to many cloud services
- Requires key in exporter manifests to specify programs required to run the exporter

## [1.1.0] - 2024-04-14
Expand Down Expand Up @@ -58,14 +61,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release

[Unreleased]: https://github.com/ortfo/db/compare/v1.0.0...HEAD
[1.1.0]: https://github.com/ortfo/db/-/releases/tag/v1.1.0
[Unreleased]: https://github.com/ortfo/db/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/ortfo/db/compare/v1.0.0...v1.1.0
[1.0.0]: https://github.com/ortfo/db/compare/v0.3.2...v1.0.0
[0.3.2]: https://github.com/ortfo/db/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/ortfo/db/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/ortfo/db/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/ortfo/db/releases/tag/v0.2.0

[//]: # (C3-2-DKAC:GGH:Rortfo/db:Tv{t})

[unreleased]: https://github.com/ortfo/db/-/compare/v1.1.0...main
18 changes: 18 additions & 0 deletions exporters/cloud.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Cloud Exporter

requires:
- rclone

data:
# Path to the Google Drive folder
path:

# Name of the rclone remote(s)
remotes:

after:
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to{{ range $remote := (index .Data "remotes") }} {{$remote}}:{{ index $.Data "path" }}, {{ end }}[dim]with rclone']
- run: >-
{{ range $remote := (index .Data "remotes") }}
rclone copy --progress {{ $.Ctx.OutputDatabaseFile }} {{$remote}}:{{ index $.Data "path" }}
{{ end }}
19 changes: 19 additions & 0 deletions exporters/ftp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: FTP Uploader

requires:
- curl

data:
username:
password:
host:
path:
secure: true
dry run: false

after:
- log: [Uploading, blue, '{{ .Ctx.OutputDatabaseFile }} to {{if (index .Data "secure")}}s{{end}}ftp://{{ index .Data "host" }}/{{ index .Data "path" }}']
- run: >-
{{if .DryRun}} echo {{end}}
curl -T {{ .Ctx.OutputDatabaseFile }}
{{if (index .Data "secure")}}sftp://{{else}}ftp://{{end}}{{index .Data "username"}}:{{index .Data "password"}}@{{ index .Data "host" }}/{{ index .Data "path" }}
22 changes: 22 additions & 0 deletions exporters/git.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Git Uploader

requires:
- git

data:
# URL to the Git repository
url:
# Commit message used
commit:

after:
# - run: test ! -d .ortfodb-tmp || echo .ortfodb-tmp exists, please remove it >&2; exit 1
- log: [Cloning, blue, 'repository {{ index .Data "url" }}']
- run: git clone {{ index .Data "url" }} .ortfodb-tmp
- log: [Comitting, blue, "{{ .Ctx.OutputDatabaseFile }} to the repository"]
- run: cp {{ .Ctx.OutputDatabaseFile }} .ortfodb-tmp
- run: cd .ortfodb-tmp && git add {{ .Ctx.OutputDatabaseFile }} && git commit -m '{{ index .Data "commit" }}'
- log: [Pushing, blue, "changes to the repository"]
- run: cd .ortfodb-tmp && git push
- log: [Cleaning up, dim, ".ortfodb-tmp directory"]
- run: rm -rf .ortfodb-tmp

0 comments on commit 3e07247

Please sign in to comment.