Single-Job Workflow (Reference)
For comparison, here’s a simple workflow that runs an ASCII script in one job:Multi-Job Workflow: Build, Test, and Deploy
Below is the enhanced workflow defining three independent jobs:build_job_1, test_job_2, and deploy_job_3.
By default, each job executes on a clean runner and does not share files. Use artifact actions or define dependencies to pass data between jobs.
Job Overview
| Job Name | Purpose | Key Steps |
|---|---|---|
build_job_1 | Build & Generate Artifacts | Install cowsay, create dragon.txt, sleep |
test_job_2 | Validate Build Output | Wait 10 s, verify dragon.txt |
deploy_job_3 | Deployment Simulation | Display file, simulate deployment |
Understanding Each Job
build_job_1
- Runner: Ubuntu latest
- Actions:
- Installs the
cowsayutility - Generates ASCII art into
dragon.txt - Simulates build time with
sleep 30
- Installs the
test_job_2
- Runner: Ubuntu latest
- Actions:
- Waits 10 seconds
- Uses
grepto ensuredragon.txtcontains “dragon” - Fails if the file is missing or the content isn’t found
deploy_job_3
- Runner: Ubuntu latest
- Actions:
- Outputs the content of
dragon.txt - Simulates deployment via
echo "Deploying..."
- Outputs the content of
Execution Behavior and Common Pitfalls
When you commit and push this workflow (e.g.,git commit -m "Add multi-job workflow"), GitHub Actions triggers all jobs in parallel:
Each job runs in isolation on its own VM. Without artifacts or explicit job dependencies, files like
dragon.txt won’t persist across jobs.
Since
test_job_2 may start before build_job_1 finishes, any attempt to read dragon.txt will trigger a file-not-found error.
test_job_2:
deploy_job_3:
Summary of Issues
- Parallel execution without defined dependencies
- Isolated environments prevent file sharing