Running a series of shell commands directly in a workflow can quickly become messy. By placing your commands in a standalone script file and invoking it in one step, you maintain a clean, maintainable workflow.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Table of Contents
| Step | Description | File/Command |
|---|---|---|
| 1 | Create the shell script | ascii-script.sh |
| 2 | Show a failing workflow (permission error) | ./ascii-script.sh |
| 3 | Update workflow to grant execute rights | chmod +x ascii-script.sh |
| 4 | Verify successful run | Actions → Logs |
1. Create the Shell Script
In your repository root, add a file namedascii-script.sh:
Make sure your script uses a Unix-style line ending (
LF) and the correct shebang (#!/bin/sh).2. Example: Workflow Fails Due to Permissions
A minimal workflow that invokes the script directly will fail because the checked-out file isn’t executable by default:Without executable permissions, the runner cannot invoke your script. Always ensure your scripts are marked as executable before running.
3. Grant Execute Permissions in Workflow
Update the workflow to add achmod +x step before executing:
4. Verify the Workflow Run
- Go to the Actions tab and select your latest workflow.
-
In List Files Before Run, notice
ascii-script.shis still-rw-r--r--: -
The Make Script Executable and Run step applies
chmod +xand executes the script. You’ll see: -
Finally, the script’s
ls -ltrashows both the executable script and generateddragon.txt: