Workflow
Workflow Definition
A workflow is a yaml which defines the workflow metadata, arguments, environment variable, checks and workflow jobs.
Metadata
Define the workflow name, and the working directory that the workflow runs.
The working-dir is optional, if it's not set, it will use the dir where is the workflow launched.
Checks and Arguments
If the workflow needs arguments or requires run as a root user, we can define it,
checks:
requires-root: true # or false
private-key: false # or true
args:
- name: arg1
pattern: "\\d+"
- name: arg2
The requires-root will check if the nadleeh is launched by the root user or sudo, if it's true and workflow is not running as a root user, the workflow will abort.
The private-key will check if the argument --private run command is specified.
The args defines a list of workflow file arguments.
- The name is required. You can use the name to get the value in the workflow during the runtime.
- The pattern is optional
- If it's not specified, the argument is optional
- If it's specified, the argument is required, and the workflow will validate the argument value using the pattern
- Boolean argument If a argument has no pattern, and it's specified with not value like
-a bool_arg, then the workflow will set the value of thebool_argas stringtrue.
You can show the workflow arguments usage with command
nadleeh run -f workflow.yml --usage.
Environments
Static environments
You can define static environemnts like
Env File
You can define env file into path ~/.nadleeh, then load like the following,
The workflow will load the static environment first, then load the env file.
Jobs
We can define workflow job using bash, javascript or plugin.
jobs:
job_name:
env:
job_env: job_env_value
steps:
- name: bash
env:
step_env: step_env
run: |
echo "run in bash"
- name: javascript
script: |
console.log("this is javascript")
- name: plugin
uses: nadleehz/file-backup@v1.0.1
with:
base_backup_dir: /opt/backup
backup_cfg: |
backups:
- src_dir: /etc/systemd/system
dst_dir: systemd
skip_non_exist: true
files:
- gundam.service
- mkdocs-cms.service
- sshd.service
- node-exporter.service
- nginx-prometheus-exporter.service
Plugins
See plugins introduction.