Introduction
Did you know that 70% of CI/CD pipelines take over an hour to set up, but with GitHub Actions, you can build a pipeline in just 10 minutes? In this tutorial, you will build a fully functional CI/CD pipeline using GitHub Actions, allowing you to automate your development workflow and save valuable time. As we move into 2026, automating workflows is becoming increasingly important for developers to stay efficient and competitive. To get started, you will need:
- A GitHub account
- A basic understanding of YAML
- A Python project to test the pipeline
- Docker installed on your machine
Table of Contents
- Introduction
- Step 1 — Create a GitHub Actions Workflow
- Step 2 — Define the Build Step
- Step 3 — Add a Test Step
- Step 4 — Deploy to Production
- Step 5 —Trigger the Workflow
- Real-World Usage
- Real-World Application
- Conclusion
- Your Turn
Step 1 — Create a GitHub Actions Workflow
Creating a GitHub Actions workflow is the first step in building your CI/CD pipeline. This step matters because it sets up the foundation for your automation process. Create a new file in your repository's .github/workflows directory, named main.yml, and add the following code:
name: Main Workflow
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
Expected output: A new workflow file created in your repository.
Step 2 — Define the Build Step
Defining the build step is crucial for compiling your code and preparing it for deployment. Add the following code to your main.yml file:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
Expected output: Your code is checked out, Python is set up, and dependencies are installed.
Step 3 — Add a Test Step
Adding a test step ensures that your code is validated before deployment. Add the following code to your main.yml file:
- name: Run tests
run: |
python -m flake8 .
Expected output: Your code is tested using Flake8.
Step 4 — Deploy to Production
Deploying to production is the final step in your CI/CD pipeline. For this example, we will use Docker to deploy our application. Add the following code to your main.yml file:
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push image
run: |
docker build -t my-app .
docker tag my-app ${{ secrets.DOCKER_USERNAME }}/my-app
docker push ${{ secrets.DOCKER_USERNAME }}/my-app
Expected output: Your Docker image is built, tagged, and pushed to DockerHub.
Step 5 — Trigger the Workflow
Triggering the workflow is the final step in building your CI/CD pipeline. To trigger the workflow, simply push changes to your repository's main branch.
Real-World Usage
Now that you have built your CI/CD pipeline, you can use it to automate your development workflow. For example, you can use the pipeline to build and deploy a web application. Simply update your main.yml file to include the necessary steps for your application.
Real-World Application
The CI/CD pipeline you just built can be used to solve real-world problems, such as automating the deployment of a web application. You can use services like Vultr Cloud (Get $100 free credit to host your apps) or DigitalOcean (Get $200 free credit to deploy your code) to host your application.
Conclusion
In this tutorial, you built a fully functional CI/CD pipeline using GitHub Actions. Here are three key takeaways:
- GitHub Actions is a powerful tool for automating your development workflow.
- You can use GitHub Actions to build, test, and deploy your application.
- Automating your workflow can save you valuable time and increase efficiency. What to build next? Try integrating your pipeline with other tools and services to further automate your workflow. Check out the rest of the Zero-Cost Cloud & DevOps series for more tutorials and guides.
💬 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:
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)