3 Workflows
This chapter covers
- Understanding YAML and the YAML syntax
- Learning the basics of the workflow syntax
- Understanding workflow triggers, expressions, and contexts
- Introducing advanced workflow concepts, like workflow commands
- Learning best practices for authoring and debugging workflows
Now that you have gained a bit of practical experience, it is time to fully understand the syntax for workflows. Since workflows are written in YAML, it is important to fully understand YAML before writing workflows.
3.1 YAML
YAML, which stands for YAML Ain’t Markup Language, is a data-serialization language optimized to be directly writable and readable by humans. It is a strict superset of JSON but with syntactically relevant newlines and indentation instead of braces. In the next sections, we go through all the YAML elements that are important for writing workflows.
3.1.1 YAML basics
YAML files are text files with a .yml or .yaml extension. Because YAML uses indentation instead of braces, these text files can be versioned very well with Git, as changes are always made per line.
YAML files can have different encodings, but GitHub uses UTF-8 for the workflows. You can write comments in YAML by prefixing text with a hash (#):
# A full-line comment in YAML key:value # An in-line comment
Comments can occur anywhere in a line.
3.1.2 Data types
In YAML, you have various data types available. There are simple (scalar) data types as well as more complex collection types.