Skip to main content
In this guide, you’ll learn how to streamline your GitHub Actions workflow by combining multiple shell commands into a single step and integrating a third-party CLI tool (cowsay). This approach reduces verbosity and keeps your CI/CD pipeline maintainable.

Workflow with Separate Steps

Initially, our workflow consisted of four discrete steps:
While functional, this pattern can become repetitive as your CI job grows.

Combining Multiple Commands in One Step

You can collapse several shell commands under a single run key by using a multiline pipe (|). Each command executes in sequence on the same virtual environment.
Grouping commands reduces the number of workflow steps and improves readability. Remember that if any command fails, the entire step stops.

Adding a Third-Party CLI Tool

Next, let’s use cowsay—a fun ASCII art generator—to create a dragon illustration and append it to dragon.txt:
The default Ubuntu runner does not include cowsay. You must install it before running the command.

Installing Dependencies

Add an installation step immediately before invoking cowsay:

Complete Workflow Example

Putting it all together, here’s your optimized workflow:

Troubleshooting

Once you commit and push these changes, navigate to the Actions tab to monitor your workflow. If you forget to install cowsay, you’ll see a failure like this:
The image shows a GitHub Actions workflow interface with a job named "first_job" that has failed. The steps include setting up the job, checking out the repository, listing and reading a file, generating ASCII artwork, and completing the job.

References

Watch Video