← Back to Git Course | Chapter 9: CI/CD & DevOps | Lesson 1 of 5

Git GitHub Actions Introduction

What is GitHub Actions?

GitHub Actions is an automation platform built directly into GitHub. It lets you automate software development workflows like testing, building, and deploying your code. Every workflow is triggered by an event, such as pushing new code to your repository.

Example: What is GitHub Actions?

bash
# .github/workflows/ci.yml
name: CI
on: push

Defining a Workflow File

Workflows are written as YAML files inside .github/workflows/, and each one declares a name plus an on: key specifying what event triggers it. GitHub picks up any correctly formatted file in that directory automatically — no separate registration step needed.

Example: Defining a Workflow File

bash
name: CI
on:
  push:
    branches: [main]

Understanding Events

Events are what start a workflow run — push, pull_request, schedule (cron syntax for timed runs), and workflow_dispatch (a manual trigger button) are the most common. A workflow can listen for several event types at once and even filter by branch or file path.

Example: Understanding Events

bash
on:
  push:
  pull_request:
  schedule:
    - cron: "0 0 * * *"
  workflow_dispatch:

Jobs and Steps

A workflow is made of one or more jobs, and by default GitHub runs them all in parallel on separate virtual machines — you use needs: to force one job to wait for another. Within a job, steps run sequentially, top to bottom, on the same machine.

Example: Jobs and Steps

bash
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: npm test
  deploy:
    needs: test
    runs-on: ubuntu-latest

Using Pre-built Actions

You do not have to write all commands from scratch. You can import pre-built, community-maintained actions using the uses keyword to handle complex tasks like checking out your code or setting up environments.

Example: Using Pre-built Actions

bash
steps:
  - uses: actions/checkout@v4
  - uses: actions/setup-node@v4
🔒

Chapter Quiz — Complete all 5 topics to unlock

0/5 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.