When working with workflows, you may find that you have repetitive tasks that you wish to re-use. To cut down on repeating tasks, Sail CI supports using the "from:" property against a workflow item.
Let's take the following task as an example. The top-level task "build-push"builds and pushes a container as part of a monorepo using Kaniko.
Example Project Structure
- SHORT_SHA: $(SAIL_COMMIT_SHORT_SHA)
- PACKAGE: "package-1"
- PACKAGE: "package-2"
Once specifying a name for the workflow item and the "from:" property you can then declare task properties. The behaviour of each property, when declared on a workflow item, as defined below:
The full schema for a workflow item:
command: ["replace", "command"]
args: ["replace", "args"]
env: ["MERGE": "ENV_VARS"]
mounts: ["/path": "MERGE_MOUNTS"]
The example above shows assigning the PACKAGE env, each time the "build-push" task runs $(PACKAGE) get replaced with the value. Saving repetition of top-level tasks for each package (e.g. "build-push-package-1", "build-push-package-2").
Note: You must specify "from:" if you name a task in your workflow that is not declared at the top-level within "tasks:".
As you can see you now have full flexibility for declaring base properties on top-level tasks that can be re-used in a workflow.