Introduction to GitHub Actions
Understand the core concepts of GitHub Actions, including workflows, events, jobs, and steps.
Introduction to GitHub Actions is a free DevOps Bootcamp lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Intro to GitHub Actions
Welcome to GitHub Actions! This powerful feature on GitHub lets you automate tasks right in your repository.
Think of it as your personal robot assistant for code. It can build your projects, run tests, or even deploy your website automatically whenever you make changes.
In this lesson, we'll explore the core concepts: workflows, events, jobs, and steps.
Workflows: Your Automation Blueprint
At the heart of GitHub Actions is the workflow. A workflow is an automated procedure that runs one or more jobs.
- Workflows are defined in YAML files.
- These files live in the
.github/workflowsdirectory of your repository. - Each workflow file represents a separate automation process.
When certain events occur (like pushing code), your workflows spring into action!
Anatomy of a Workflow File
GitHub Actions workflows are written in YAML, a human-friendly data serialization standard. Here's a basic structure:
name: My First Workflow
on: [push]
jobs:
my_first_job:
runs-on: ubuntu-latest
steps:
- name: Greet Me
run: echo "Hello CoddyKit!"Events: Triggers for Automation
Events are specific activities that trigger your workflow to run. They tell GitHub Actions when to start the automation process.
Common events include:
push: When code is pushed to the repository.pull_request: When a pull request is opened, updated, or closed.schedule: To run at specific times (like a cron job).
You can specify one or more events in your workflow file using the on: keyword.
name: On Push Example
on: [push, pull_request] # This workflow runs on push or pull request events
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run a simple command
run: echo "Code was pushed or PR updated!"Jobs: Organized Tasks
A job is a set of steps that execute on the same runner. Workflows are made up of one or more jobs, which can run in parallel or sequentially.
- Each job runs in a fresh instance of the virtual environment specified by
runs-on. - Common
runs-onvalues includeubuntu-latest,windows-latest, andmacos-latest.
Jobs define what needs to be done, like building an application or running tests.
Steps: Individual Instructions
Within a job, steps are individual tasks that get executed. A step can be:
- A command-line script (using
run). - An action (using
uses) – a reusable piece of code.
Steps are executed in the order they are defined. If one step fails, by default, the job fails and subsequent steps are skipped.
name: Steps Demo
on: [push]
jobs:
my_job:
runs-on: ubuntu-latest
steps:
- name: Step 1: Say Hello
run: echo "Hello from Step 1!"
- name: Step 2: List files
run: ls -la
- name: Step 3: Echo another message
run: echo "Step 3 completed."Actions: Reusable Code Blocks
Actions are the most granular unit of automation. They are reusable pieces of code that perform a specific task.
Instead of writing complex scripts for common tasks, you can use existing actions from the GitHub Marketplace or create your own.
- Use the
uses:keyword to reference an action. - Actions can be from GitHub (e.g.,
actions/checkout), a Docker image, or a JavaScript file.
This saves time and promotes consistency!
name: Using Actions
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository code
uses: actions/checkout@v4 # This action checks out your repo
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm installBuilding a Full Workflow
Let's combine everything we've learned into a single, runnable workflow example. This workflow will simply check out your code and print a greeting.
This YAML file would be saved as .github/workflows/greeting.yml in your repository.
name: Simple Greeting Workflow
on: [push] # Triggers on any push to the repository
jobs:
greet_job:
runs-on: ubuntu-latest # Runs on a fresh Ubuntu virtual machine
steps:
- name: Checkout the repository
uses: actions/checkout@v4 # Action to get your code
- name: Say hello
run: echo "Hello, GitHub Actions User!" # A simple command-line step
- name: Show current directory
run: pwd # Another command to show where we areHow a Workflow Executes
When an event (like a push) occurs, GitHub Actions:
- Reads the relevant workflow YAML file from
.github/workflows/. - Initializes a virtual machine (a runner) for each job.
- Executes each step within the job sequentially.
- Reports the status (success/failure) of each step and the overall job.
You can monitor this process in the "Actions" tab of your GitHub repository.
Quick Check: Workflow Components
Which of the following are essential components found in a GitHub Actions workflow file?
Recap: GitHub Actions Intro
Great job! You've learned the foundational concepts of GitHub Actions:
- Workflows: Your automation blueprints in YAML files.
- Events: Triggers that start your workflows.
- Jobs: Sets of steps that run on a runner.
- Steps: Individual commands or reusable actions.
- Actions: Reusable units of work for common tasks.
Next, we'll dive into building more practical CI/CD workflows!
Frequently asked questions
Is the “Introduction to GitHub Actions” lesson free?
Yes — the full text of “Introduction to GitHub Actions” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “Introduction to GitHub Actions”?
Understand the core concepts of GitHub Actions, including workflows, events, jobs, and steps. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Introduction to GitHub Actions” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Introduction to GitHub Actions
- Building CI/CD Workflows
- Custom Actions & Marketplace
- Secrets and Environment Variables in Actions