v0.10.0
Some checks failed
ci/woodpecker/push/go-lint Pipeline failed
ci/woodpecker/push/publish-docs Pipeline was successful

This commit is contained in:
Andrew Woodlee 2025-03-03 23:46:26 -06:00
parent 753b03861f
commit bcba6b2086
15 changed files with 228 additions and 0 deletions

View File

@ -0,0 +1,3 @@
kind: Added
body: 'Hooks: improved logging when executing'
time: 2025-03-01T13:29:32.195438013-06:00

View File

@ -0,0 +1,3 @@
kind: Added
body: 'User commands: adding SSH keys using config key `userSshPubKeys`'
time: 2025-03-03T23:42:48.009294808-06:00

View File

@ -0,0 +1,3 @@
kind: Added
body: 'directives: added support for fetching values using directive `%{externalSource:key}%`'
time: 2025-03-03T23:45:05.666939653-06:00

View File

@ -0,0 +1,3 @@
kind: Changed
body: 'Commands: if dir is not specified, run in config dir'
time: 2025-03-01T19:43:21.323077376-06:00

View File

@ -0,0 +1,3 @@
kind: Fixed
body: 'LocalFetcher: return fetch error'
time: 2025-03-01T13:26:00.330176712-06:00

View File

@ -0,0 +1,3 @@
kind: Fixed
body: 'Lists: load file key before attempting to load from current file'
time: 2025-03-01T13:28:01.739467944-06:00

View File

@ -0,0 +1,3 @@
kind: Fixed
body: 'fix: host not in config file, but in ssh config, properly added to hosts struct'
time: 2025-03-01T18:24:34.81395054-06:00

View File

@ -0,0 +1,108 @@
commands:
stop-docker-container:
cmd: docker
Args:
- compose
- -f /some/path/to/docker-compose.yaml
- down
# if host is not defined, cmd will be run locally
host: some-host
hooks:
final:
- hostname
error:
- hostname
backup-docker-container-script:
cmd: /path/to/script
# The host has to be defined in the config file
host: some-host
environment:
- FOO=BAR
- APP=$VAR
shell-cmd:
cmd: rsync
shell: bash
Args:
- -av some-host:/path/to/data ~/Docker/Backups/docker-data
hostname:
cmd: hostname
update-docker:
type: package
shell: zsh # best to run package commands in a shell
packageName: docker-ce
Args:
- docker-ce-cli
packageManager: apt
packageOperation: install
update-dockerApt:
# type: package
shell: zsh
cmd: apt
Args:
- update
- "&&"
- apt install -y docker-ce
- docker-ce-cli
packageManager: apt
packageOperation: install
cmd-lists:
cmds-to-run: # this can be any name you want
# all commands have to be defined
order:
- stop-docker-container
- backup-docker-container-script
- shell-cmd
- hostname
notifications:
- matrix.matrix
name: backup-some-server
cron: "0 0 1 * * *"
hostname:
name: hostname
order:
- hostname
notifications:
- mail.prod-email
hosts:
# any ssh_config(5) keys/values not listed here will be looked up in the config file or the default config file
some-host:
hostname: some-hostname
config: ~/.ssh/config
user: user
privatekeypath: /path/to/private/key
port: 22
# can also be env:VAR
password: file:/path/to/file
# only one is supported for now
proxyjump: some-proxy-host
# optional
logging:
verbose: true
file: ./backy.log
console: false
cmd-std-out: false
notifications:
mail:
prod-email:
id: prod-email
type: mail
host: yourhost.tld
port: 587
senderAddress: email@domain.tld
to:
- admin@domain.tld
username: smtp-username@domain.tld
password: your-password-here
matrix:
matrix:
id: matrix
type: matrix
home-server: your-home-server.tld
room-id: room-id
access-token: your-access-token
user-id: your-user-id

View File

@ -0,0 +1,24 @@
commands:
stop-docker-container:
cmd: docker
Args:
- compose
- -f /some/path/to/docker-compose.yaml
- down
# if host is not defined, command will be run locally
# The host has to be defined in either the config file or the SSH Config files
host: some-host
hooks:
error:
- some-other-command-when-failing
success:
- success-command
final:
- final-command
backup-docker-container-script:
cmd: /path/to/local/script
# script file is input as stdin to SSH
type: scriptFile # also can be script
environment:
- FOO=BAR
- APP=$VAR

View File

@ -0,0 +1,3 @@
{{ $file := .Get "file" | readFile }}
{{ $lang := .Get "language" }}
{{ (print "```" $lang "\n" $file "\n```") }}

24
examples/example.yml Normal file
View File

@ -0,0 +1,24 @@
commands:
stop-docker-container:
cmd: docker
Args:
- compose
- -f /some/path/to/docker-compose.yaml
- down
# if host is not defined, command will be run locally
# The host has to be defined in either the config file or the SSH Config files
host: some-host
hooks:
error:
- some-other-command-when-failing
success:
- success-command
final:
- final-command
backup-docker-container-script:
cmd: /path/to/local/script
# script file is input as stdin to SSH
type: scriptFile # also can be script
environment:
- FOO=BAR
- APP=$VAR

1
tests/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
private

17
tests/ErrorHook.yml Normal file
View File

@ -0,0 +1,17 @@
commands:
echoTestFail:
cmd: ech
shell: bash
Args: hello world
hooks:
error:
- errorCmd
errorCmd:
name: get docker version
cmd: docker
getOutput: true
outputToLog: true
Args:
- "-v"
host: email-svr

14
tests/HookNotInFile.yaml Normal file
View File

@ -0,0 +1,14 @@
commands:
echoTestFail:
cmd: ech
shell: bash
Args: hello world
hooks:
error:
- errorCm #
errorCmd:
name: get docker version
cmd: docker
Args:
- "-v"

16
tests/SuccessHook.yml Normal file
View File

@ -0,0 +1,16 @@
commands:
echoTestSuccess:
cmd: echo
shell: bash
Args: hello world
hooks:
success:
- successCmd
errorCmd:
name: get docker version
cmd: docker
getOutput: true
outputToLog: true
Args:
- "-v"