> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Github Actions Basics

> Introduction to GitHub Actions explaining workflows, jobs, steps, runners, matrix strategies, and hosted versus self hosted runners for CI/CD and repository automation

Get a concise introduction to GitHub Actions — an integrated automation platform for repositories hosted on GitHub. If your code already lives on GitHub, Actions offers a seamless way to build CI/CD pipelines, run repository automations, and respond to events without adopting an external CI system.

What is GitHub Actions?

GitHub Actions is a flexible automation platform built into GitHub. You define automated processes as workflows using YAML files stored in your repository, and GitHub executes those workflows in response to repository events. With Actions you can:

* Build, test, and deploy code on pushes and pull requests.
* Run checks and analyses (linting, security scans, dependency updates).
* Orchestrate repository automations (comment bots, labeling, notifications).
* Schedule workflows or trigger them from webhooks and other GitHub events.

Workflows and jobs can run on multiple operating systems, including Ubuntu, Windows, and macOS.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-ubuntu-windows-macos.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=93fbf7403e16506aaa4831b4249ed1fc" alt="A slide titled &#x22;GitHub Actions&#x22; showing three numbered OS icons: Ubuntu (orange), Windows (pink) and MacOS (green). Each OS is shown as a rounded-square logo with the labels &#x22;1&#x22;, &#x22;2&#x22;, and &#x22;3.&#x22;" width="1920" height="1080" data-path="images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-ubuntu-windows-macos.jpg" />
</Frame>

Why choose GitHub Actions?

* Hosted infrastructure managed by GitHub (provisioning, scaling, and maintenance).
* Declarative workflows in YAML that live with your code (`.github/workflows/`).
* Built-in capabilities: dependency caching, artifact storage, and detailed logs.
* Automation reduces manual steps, lowers human error, and accelerates delivery.

Is GitHub Actions only for CI/CD pipelines?

No. CI/CD (build, test, release) is a primary use case, but Actions can run workflows on many repository events — pushes, pull requests, issues, package registry events, and more. For example, when a contributor opens a pull request you can automatically add labels, assign reviewers, post comments, or run security scans.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-ci-cd-pipeline-steps.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=365df30cc7a7ec6dfaccfbd72f93c113" alt="A GitHub Actions diagram with the GitHub logo over a box labeled &#x22;Automate CI/CD.&#x22; Below it are icons for pipeline steps: Building, Unit Testing, Linting, Dockerizing, Security, Deployment, and Tests." width="1920" height="1080" data-path="images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-ci-cd-pipeline-steps.jpg" />
</Frame>

Core concepts: workflows, jobs, steps, and runners

* Workflow: an automated process defined in a YAML file stored in `/.github/workflows/`. A repository can contain multiple workflows triggered by different events.
* Job: a group of steps that runs on a single runner. Jobs run in parallel by default unless you specify dependencies with `needs`.
* Step: a single task in a job. Steps run sequentially within a job.
* Runner: the machine (virtual or physical) that executes a job. Runners are either GitHub-hosted or self-hosted.

Quick reference table

| Concept  | Purpose                               | Example                        |
| -------- | ------------------------------------- | ------------------------------ |
| Workflow | Defines automation and triggers       | `/.github/workflows/ci.yml`    |
| Job      | Group of steps that run on one runner | `jobs: build:`                 |
| Step     | Single task (action or command)       | `- name: Install dependencies` |
| Runner   | Execution environment                 | `runs-on: ubuntu-latest`       |

Matrix strategy and parallel jobs

A common pattern uses a matrix strategy to run the same job across multiple OSes or versions. Each matrix entry becomes a separate job executed concurrently on its own runner.

Example: run tests on Ubuntu, macOS, and Windows

```yaml theme={null}
name: My Awesome App
on: push
jobs:
  unit-testing:
    name: Unit Testing
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node-version: [16]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set up Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      - name: Install dependencies
        run: npm ci

      - name: Run tests
        run: npm test
```

Execution notes

* GitHub provisions a separate runner for each matrix job concurrently (three runners in the example).
* Steps inside a job execute sequentially (checkout → setup → install → test).
* Each matrix job is evaluated independently: a matrix instance’s success or failure is reported separately. The overall workflow succeeds only when all required jobs complete successfully.
* You can view logs, step output, and artifacts for each job in the repository’s Actions tab.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-hosted-runners-nodejs-tests.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=e45721cb8b008303fb67cee21096f91d" alt="A screenshot of a GitHub Actions run on the left showing jobs and detailed unit-testing steps, and on the right three colored diagrams of GitHub-hosted runners (Windows, Ubuntu, macOS) each performing &#x22;Clone Repo,&#x22; &#x22;Install NodeJS,&#x22; and &#x22;Run Tests.&#x22;" width="1920" height="1080" data-path="images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/github-actions-hosted-runners-nodejs-tests.jpg" />
</Frame>

Runner types — GitHub-hosted vs. self-hosted

There are two main runner options:

| Runner type   | Pros                                                                                               | Cons                                                                          | When to use                                                                     |
| ------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| GitHub-hosted | No server maintenance; fresh environment per job; common tooling preinstalled                      | Limited control over system-level config; usage subject to GitHub plan limits | Best for typical CI/CD where convenience and low ops overhead matter            |
| Self-hosted   | Full control over OS, installed software, and network access; can access private resources or GPUs | You manage maintenance, scaling, and security                                 | Use when you need custom software, specific hardware, or private network access |

<Callout icon="lightbulb" color="#1CB2FE">
  Choose GitHub-hosted runners for convenience and low maintenance. Choose self-hosted runners when you need custom software, special hardware, or specific network access that hosted runners can't provide.
</Callout>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/XTR6jhnagwAdsrpZ/images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/runner-types-github-vs-self-hosted.jpg?fit=max&auto=format&n=XTR6jhnagwAdsrpZ&q=85&s=0527c59f43b788f7256b0757c69cec9e" alt="An infographic titled &#x22;Runner Types&#x22; that compares GitHub-hosted Runners (green) and Self-hosted Runners (orange) with icons and bullet-pointed features and trade-offs. The bottom shows colored buttons for Workflow, Jobs, Steps, and Runners." width="1920" height="1080" data-path="images/Advanced-Jenkins/Backup-and-Configuration-Management/Github-Actions-Basics/runner-types-github-vs-self-hosted.jpg" />
</Frame>

Summary and next steps

This article covered the essentials of GitHub Actions: what it is, how workflows, jobs, steps, and runners relate, how matrix jobs enable parallel runs across OSes, and the differences between GitHub-hosted and self-hosted runners. Use these fundamentals to design CI/CD workflows and repository automations.

Further reading and references

* GitHub Actions docs: [https://docs.github.com/actions](https://docs.github.com/actions)
* Actions marketplace: [https://github.com/marketplace?type=actions](https://github.com/marketplace?type=actions)
* actions/checkout: [https://github.com/actions/checkout](https://github.com/actions/checkout)
* actions/setup-node: [https://github.com/actions/setup-node](https://github.com/actions/setup-node)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/advanced-jenkins/module/6f55f1ac-064a-4aec-a91a-450caaf82d63/lesson/9ec91e18-757e-464f-88b6-91c52c580116" />
</CardGroup>
