Skip to main content
Running multiple commands as separate run steps can clutter your GitHub Actions workflow. By bundling them into a single shell script, you simplify maintenance, improve readability, and reduce duplication.

1. Why Consolidate run Steps?

When you split each command into its own run, your workflow becomes long and harder to manage:

2. Create a Reusable Shell Script

Add a file named ascii-script.sh at the root of your repository with all commands:
Make sure to commit this script:
You can reference this pattern for any multi-step process—testing, building, or deployment—by swapping commands in your script.

3. Refactor Your Workflow to Invoke the Script

Update your workflow to run only the script:
After pushing, navigate to the Actions tab to see your new workflow run:
The image shows a GitHub Actions page with a list of workflow runs, displaying their status, branch, and timestamps. Some workflows are marked as successful, while others have failed or are in progress.

4. Troubleshoot “Permission denied”

If you see an exit code 126, it means the script lacks execute permissions:
The image shows a GitHub Actions page where a workflow named "Executing Shell Script" has failed. The job "ascii_job" completed with an exit code 126.
Always ensure your script is executable. You can either set the permission locally with chmod +x ascii-script.sh before committing, or update your workflow to grant permissions at runtime.

5. Grant Execute Permissions in the Workflow

Modify the step to add execution rights before running the script:
Commit and push these changes to restart the workflow.

6. Verify the Successful Run

When the workflow reruns, you’ll see:
And then:
Your script installs Cowsay, generates ASCII art, searches and displays content, and lists files—all in one step.

References

Watch Video