There are two different ways to run shell commands in GitHub actions: the Literal Block Scalar (run: |
) and the Folded Block Scalar (run: >
). Here’s the difference.
Prerequisites
- GitHub
Solution
literal block scalar
This one being run: |
where each line is treated as a separate command in the shell. For instance:
- name: Literal Block Scalar step
run: |
echo "first line"
echo "second line"
echo "third line"
Readable, maintainable, cleaner (IMO) and preserves formatting.
folded block scalar
Basically the lines are concatenated into a single one before being executed. Example:
- name: Folded Block Scalar step
run: >
echo "first command";
echo "second command";
echo "third command"
Conclusion
In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.