Published on

How to Create a CI/CD Pipeline With GitHub Actions in 2026

GitHub Actions allows you to automate your software development workflow by creating a CI/CD pipeline (Continuous Integration and Continuous Delivery - a method to frequently deliver apps by introducing automation into the stages of app development) in under 10 minutes. By placing a simple YAML file (Yet Another Markup Language - a human-readable data format used for configuration files) in your repository, you can automatically test, build, and deploy your code every time you push a change. This automation reduces manual errors and ensures your project remains stable as you grow.

What are the core components of a GitHub Actions pipeline?

Before you start writing code, you need to understand the building blocks of the system. A "Workflow" is the highest-level container for your automation process, which is triggered by an "Event" (an action like pushing code or opening a pull request). Inside a workflow, you have "Jobs," which are sets of steps that execute on a "Runner" (a virtual server hosted by GitHub or yourself).

Each job contains multiple "Steps" that perform specific tasks, such as installing dependencies or running tests. These steps often use "Actions," which are pre-built pieces of code that handle common tasks like setting up a programming language. Think of the workflow as a recipe, the jobs as the courses of a meal, and the actions as the specific ingredients you use to cook.

What do you need to get started?

To follow this guide, you should have a basic understanding of Git (a version control system used to track changes in source code). You will also need a GitHub account and a project to work on. For this tutorial, we will use a Python project, but the concepts apply to JavaScript, Ruby, or any other language.

  • A GitHub Repository: This is where your project code lives online.
  • Python 3.14+: The programming language used for our example script.
  • A Code Editor: Tools like VS Code or Cursor work best for editing YAML files.
  • Claude 4.5 or GPT-5: We recommend using these latest AI models to help you generate or debug your YAML configurations if you get stuck.

Step 1: How do you create the workflow directory?

GitHub Actions looks for instructions in a very specific location within your project folder. If the folder structure is wrong, the automation will not start.

  1. Open your project folder on your computer.
  2. Create a new folder at the root (top level) of your project named .github.
  3. Inside the .github folder, create another folder named workflows.
  4. Inside the workflows folder, create a new file named main.yml.

What you should see: Your file path should look exactly like this: your-project/.github/workflows/main.yml.

Step 2: How do you define the trigger and the runner?

Now you will tell GitHub when to run your pipeline and what kind of computer to use. Open your main.yml file and add the following lines.

# The name of the workflow as it appears in GitHub
name: Python CI Pipeline

# The 'on' section defines what triggers the workflow
on:
  push:
    branches: [ "main" ] # Runs every time you push to the main branch
  pull_request:
    branches: [ "main" ] # Runs when someone tries to merge code into main

# The 'jobs' section defines what the pipeline actually does
jobs:
  build-and-test:
    # 'runs-on' specifies the operating system for the runner
    runs-on: ubuntu-latest 

What you should see: This code sets the foundation. It tells GitHub to start a virtual Linux server (Ubuntu) every time code is updated on your main branch.

Step 3: How do you add steps to check out code and setup Python?

A fresh runner is like a brand new computer with nothing on it. You must explicitly tell it to download your code and install the necessary tools.

  1. Add a steps: header under your job.
  2. Use the actions/checkout action to copy your code onto the runner.
  3. Use the actions/setup-python action to install the correct version of Python.
    steps:
      # Step 1: Download your repository code onto the runner
      - name: Checkout repository code
        uses: actions/checkout@v6 # v6 is the 2026 standard for security

      # Step 2: Install Python 3.15 on the runner
      - name: Set up Python 3.15
        uses: actions/setup-python@v7 # v7 ensures compatibility with Node 24 runners
        with:
          python-version: "3.15"

What you should see: When this runs, GitHub will prepare the environment so it is ready to execute your specific project commands.

Step 4: How do you install dependencies and run tests?

Finally, you need to tell the pipeline to perform the actual work of checking your code for errors. This usually involves installing libraries and running a testing framework.

      # Step 3: Install the libraries your project needs
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pytest # A tool used to run Python tests
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

      # Step 4: Run your automated tests
      - name: Run tests with pytest
        run: |
          pytest

What you should see: If your tests pass, you will see a green checkmark in GitHub. If any test fails, the pipeline will stop and show a red "X," alerting you that something is broken.

How do you verify the pipeline is working?

Once you have saved your main.yml file, you need to send it to GitHub to activate it. Follow these steps to see it in action.

  1. Open your terminal or command prompt.
  2. Type git add .github/workflows/main.yml and press Enter.
  3. Type git commit -m "Add CI pipeline" and press Enter.
  4. Type git push origin main to upload the file to GitHub.
  5. Go to your repository on GitHub.com and click the "Actions" tab at the top.

What you should see: You will see a new entry titled "Python CI Pipeline." Click on it to watch the live logs as GitHub starts the runner, installs Python, and executes your tests.

What are the common mistakes beginners make?

One of the most frequent issues is incorrect indentation in the YAML file. YAML relies on spaces to understand the structure; even a single extra space can cause the entire pipeline to fail. We've found that using a code editor with a YAML extension helps highlight these spacing errors before you push your code.

Another "gotcha" is forgetting to update the versions of the actions you use. By 2026, using outdated versions like actions/checkout@v4 might trigger security warnings or fail because the underlying runner environments have moved to newer versions of Node.js. Always check for the latest version tags on the GitHub Marketplace.

Finally, remember that the runner starts with a completely empty environment. If your code relies on a specific environment variable (a dynamic value like an API key that your program needs to run), you must define it in the "Secrets" section of your GitHub repository settings and reference it in your YAML file.

How do you expand this into a CD pipeline?

Continuous Delivery (CD) is the next step, where you automatically send your code to a hosting provider like Vercel, AWS, or Railway after the tests pass. To do this, you add a second job to your workflow file that only runs if the first job is successful.

You can use the needs: build-and-test property in your YAML to ensure deployment doesn't happen if your tests fail. This creates a safety net for your project. In 2026, most hosting providers offer their own GitHub Actions that make this process as simple as adding three or four lines of configuration.

Don't worry if your first few attempts result in a red error message. It is normal to spend some time tweaking your YAML file to get the paths and dependencies exactly right. Each failure gives you a log that tells you exactly which step went wrong, making it easier to fix.

Next Steps

Now that you have a basic pipeline running, you can explore more advanced automation. You might want to add a "Linter" (a tool that checks your code for style and formatting issues) or set up automatic notifications that message you on Slack when a build fails.

For more detailed information on specific syntax and advanced features, you should visit the official GitHub Actions documentation.


Read the Create Documentation