GitHub Actions Overview: CI/CD Workflows
GitHub Actions is a CI/CD platform that integrates directly with GitHub repositories, letting you automate build, test, and deployment workflows triggered by Repository events.
What You'll Learn
In this tutorial, you'll learn what GitHub Actions is, how workflows are structured, the difference between continuous integration and continuous delivery, and how to create your first automated pipeline.
Why It Matters
Manual build and deployment processes are error-prone, slow, and inconsistent. GitHub Actions gives every Repository a built-in automation engine that runs tests on every Pull Request, deploys after every merge, and enforces code quality gates -- all without leaving GitHub.
Real-World Use
Doda Browser uses GitHub Actions to run linting, unit tests, and integration tests on every Pull Request across three operating systems. When code is merged to main, a deployment workflow builds the Docker image, pushes it to the registry, and deploys to the staging environment -- all in under 10 minutes.
What Is GitHub Actions
GitHub Actions consists of several core concepts:
- Workflow -- an automated Process defined in a YAML file
- Job -- a set of steps that run on the same runner
- Step -- an individual task, such as running a command or an action
- Action -- a reusable unit of automation code
- Runner -- a server that executes workflows
A Simple Workflow
Create .github/workflows/ci.yml in your Repository:
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm test
Workflow Components
Triggers
The on keyword defines when the workflow runs:
on:
push:
branches: [main]
schedule:
- cron: "0 2 * * 0"
workflow_dispatch:
Jobs and Steps
Jobs run in parallel by default. Use needs for sequential execution:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm run lint
test:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm test
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- run: echo "Deploying..."
Viewing Workflow Results
Navigate to the Actions tab in your GitHub Repository to see workflow runs, logs, and status badges.
Practice Questions
1. What three YAML files define a GitHub Actions workflow?
There is no specific naming requirement, but files are stored in .github/workflows/ and typically named ci.yml, deploy.yml, or release.yml.
2. What is the difference between a job and a step? A job is a group of steps that run on the same runner. A step is an individual command or action within a job.
3. How do you make jobs run sequentially?
Use the needs keyword to declare dependencies between jobs.
4. What are the four core concepts of GitHub Actions? Workflow, job, step, action, and runner.
5. Challenge: Create a workflow with three jobs: lint, test, and build. The build job should only run after test passes. Add a cron trigger to run every Monday morning.
Mini Project: Complete CI Pipeline
Create a .github/workflows/ci.yml workflow for a Node.js project. It should install dependencies, run linter, run unit tests, build the project, and upload build artifacts. Add status badges to the README. Verify the workflow runs on every push to main.
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro