DEV Community

Cover image for Build CI/CD Pipeline in 10 Mins with Free GitHub Actions
Sudhir Bahadure
Sudhir Bahadure

Posted on

Build CI/CD Pipeline in 10 Mins with Free GitHub Actions

Introduction

Last week, I spent 3 hours manually deploying my application to a cloud server, only to realize that I had missed a critical step, resulting in a failed deployment. Then, I discovered the power of automating CI/CD pipelines with free GitHub Actions, and it changed my workflow forever. In this tutorial, you will build a fully functional CI/CD pipeline in just 10 minutes using free GitHub Actions. This matters in 2026 because automating deployment processes is no longer a luxury, but a necessity, as it saves time, reduces errors, and increases productivity. To get started, you will need:

  • A GitHub account
  • A basic understanding of YAML syntax
  • A cloud server (optional, but recommended for real-world usage)
  • A Python application (optional, but recommended for real-world usage)

Table of Contents

Step 1 — Create a GitHub Actions Workflow

Creating a GitHub Actions workflow is the first step in automating your CI/CD pipeline. This matters because it sets the foundation for the entire pipeline.

# .github/workflows/main.yml
name: CI/CD Pipeline
on:
  push:
    branches:
      - main
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
Enter fullscreen mode Exit fullscreen mode

Expected output: A new workflow file will be created in your repository, and the pipeline will be triggered on push events to the main branch.

Step 2 — Define the Build and Deployment Process

Defining the build and deployment process is crucial in automating your CI/CD pipeline. This matters because it ensures that your application is built and deployed consistently.

# .github/workflows/main.yml (continued)
      - name: Install dependencies
        run: |
          pip install -r requirements.txt
      - name: Build and deploy
        run: |
          python deploy.py
Enter fullscreen mode Exit fullscreen mode

Expected output: Your application will be built and deployed to the specified environment.

Step 3 — Configure Environment Variables

Configuring environment variables is essential in automating your CI/CD pipeline. This matters because it ensures that sensitive information is not hardcoded in your workflow file.

# .github/workflows/main.yml (continued)
      - name: Configure environment variables
        env:
          SERVER_IP: ${{ secrets.SERVER_IP }}
          SERVER_PORT: ${{ secrets.SERVER_PORT }}
        run: |
          echo "Server IP: $SERVER_IP"
          echo "Server Port: $SERVER_PORT"
Enter fullscreen mode Exit fullscreen mode

Expected output: Environment variables will be set and printed to the console.

Step 4 — Add Deployment Scripts

Adding deployment scripts is the final step in automating your CI/CD pipeline. This matters because it ensures that your application is deployed to the correct environment.

# deploy.py
import os

def deploy():
    # Deploy to server
    server_ip = os.environ['SERVER_IP']
    server_port = os.environ['SERVER_PORT']
    print(f"Deploying to {server_ip}:{server_port}")

if __name__ == "__main__":
    deploy()
Enter fullscreen mode Exit fullscreen mode

Expected output: Your application will be deployed to the specified server.

Step 5 — Test and Validate the Pipeline

Testing and validating the pipeline is crucial in ensuring that it works as expected. This matters because it ensures that your application is deployed correctly and consistently.

# Test the pipeline
git push origin main
Enter fullscreen mode Exit fullscreen mode

Expected output: The pipeline will be triggered, and your application will be deployed to the specified environment.

Real-World Usage

To use the pipeline in a real-world scenario, you can deploy your application to a cloud server using a service like Vultr Cloud (Get $100 free credit to host your apps) or DigitalOcean (Get $200 free credit to deploy your code). Simply update the deploy.py script to deploy to your cloud server.

Real-World Application

This pipeline can be used to automate the deployment of any Python application to a cloud server. For example, you can use it to deploy a machine learning model to a cloud server for inference.

Conclusion

In conclusion, automating your CI/CD pipeline with free GitHub Actions can save you time, reduce errors, and increase productivity. The three key takeaways from this tutorial are:

  1. Create a GitHub Actions workflow to automate your CI/CD pipeline.
  2. Define the build and deployment process to ensure consistent deployment.
  3. Configure environment variables to ensure sensitive information is not hardcoded.

What to build next? Try automating your testing and validation process using GitHub Actions.

💬 Your Turn

Have you automated your CI/CD pipeline before? What was your approach? Drop it in the comments — I read every one.

💡 Found this helpful?

If this tutorial saved you time or solved a problem, consider:

  • Support me on Ko-fi
  • Support via PayPal

Every coffee or donation keeps me writing free tutorials like this one!


This article was written with AI assistance and reviewed for technical accuracy.
Part of the **Zero-Cost Cloud & DevOps* series — Follow for more free tutorials*

#aBotWroteThis

Top comments (0)