GitHub Actions Certification
GitHub Actions Core Concepts
Workflow with multiple Jobs
In this guide, we’ll transform a simple, single-job GitHub Actions workflow into a robust multi-job CI/CD pipeline. You’ll learn how to split build, test, and deploy stages into separate jobs, ensure proper sequencing, and share artifacts between steps.
Table of Contents
- Recap: Single-Job Workflow
- Multi-Job Workflow Setup
- Default Parallel Execution & Failures
- Common Errors
- Issues to Address Next
- References
Recap: Single-Job Workflow
Our original workflow ran every step in one job:
# .github/workflows/generate-ascii.yml
name: Generate ASCII Artwork
on: push
jobs:
ascii_job:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Execute ASCII script
run: |
chmod +x ascii-script.sh
./ascii-script.sh
This approach is simple but not scalable. Everything—from installation to deployment—occurs in a single VM instance.
Multi-Job Workflow Setup
Below is an improved workflow with three distinct jobs: build_job_1, test_job_2, and deploy_job_3. Each job runs on its own runner:
# .github/workflows/generate-ascii.yml
name: Generate ASCII Artwork
on:
push:
branches:
- main
jobs:
build_job_1:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install cowsay
run: sudo apt-get update && sudo apt-get install cowsay -y
- name: Generate ASCII dragon
run: cowsay -f dragon "Run for cover, I am a DRAGON.... RAWR" >> dragon.txt
- name: Pause for 30 seconds
run: sleep 30
test_job_2:
runs-on: ubuntu-latest
steps:
- name: Pause for 10 seconds
run: sleep 10
- name: Verify dragon.txt
run: grep -i "dragon" dragon.txt
deploy_job_3:
runs-on: ubuntu-latest
steps:
- name: Display dragon.txt
run: cat dragon.txt
- name: Simulate deployment
run: echo "Deploying dragon.txt..."
Job Overview
Job Name | Purpose | Key Steps |
---|---|---|
build_job_1 | Install dependencies & generate | Install cowsay , create dragon.txt |
test_job_2 | Validate build output | Check for “dragon” in dragon.txt |
deploy_job_3 | Output & deploy | Print file content, simulate deployment |
Default Parallel Execution & Failures
By default, GitHub Actions runs jobs in parallel on separate VMs. Since there’s no shared filesystem or enforced order, downstream jobs may start before the build completes.
Note
Jobs in GitHub Actions are isolated by default. To share files or enforce ordering, you’ll need to use job dependencies and artifacts.
Common Errors
When jobs run in parallel without dependencies, you may see errors like:
grep -i "dragon" dragon.txt
cat dragon.txt
# cat: dragon.txt: No such file or directory
# Error: Process completed with exit code 1.
Issues to Address Next
Job Sequencing
Ensurebuild_job_1
completes beforetest_job_2
, andtest_job_2
beforedeploy_job_3
using theneeds
keyword.Artifact Sharing
Useactions/upload-artifact
in the build job andactions/download-artifact
in downstream jobs to passdragon.txt
.
References
Watch Video
Watch video content