0Pricing
DevOps Bootcamp · Lesson

Building CI/CD Workflows

Create practical CI/CD pipelines to automatically build, test, and deploy your code upon pushes or pull requests.

Building CI/CD Workflows is a free DevOps Bootcamp lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Welcome to CI/CD

In this lesson, you'll learn to build powerful Continuous Integration (CI) and Continuous Deployment (CD) pipelines using GitHub Actions.

CI/CD automates your software development process, from code changes to deployment, making it faster and more reliable.

Why CI/CD Matters

Why is automation so crucial in modern software development?

  • Faster Feedback: Catch bugs and integration issues early by running tests automatically.
  • Consistent Builds: Ensure every build follows the same steps, reducing 'it works on my machine' problems.
  • Reliable Releases: Deploy new features or fixes with confidence and less manual error.
  • Improved Collaboration: Teams integrate changes frequently and seamlessly, minimizing merge conflicts.

GitHub Actions: Core Concepts

GitHub Actions uses workflows defined in YAML files. These files live in a special directory in your repository: .github/workflows/.

A workflow defines a series of jobs, and each job contains steps that execute commands or use pre-built actions. This is how you tell GitHub what to do!

Building Your First CI Workflow

Let's create a basic CI workflow that triggers on every push to your repository. It will set up Node.js and simulate a project build process.

Save this content as .github/workflows/ci.yml in your repository:

name: Node.js CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'
      - name: Install dependencies
        run: npm install
      - name: Build project
        run: node build.js

Simulating the Build Script

The node build.js command in the workflow would execute a script like this. This script simulates the work of compiling, bundling, or preparing your application's code.

Try running it to see the output:

console.log("Starting project build...");
console.log("  - Compiling source files...");
console.log("  - Bundling assets for deployment...");
console.log("Build process finished successfully!");

Adding Automated Tests

A crucial part of CI is running automated tests. Let's extend our workflow to include a test step after installing dependencies. If tests fail, the workflow fails, preventing bad code from progressing!

We'll add a test step like this:

name: Node.js CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18'
      - name: Install dependencies
        run: npm install
      - name: Run tests
        run: node test.js
      - name: Build project
        run: node build.js

Simulating the Test Script

Here's a simple test.js script that your workflow might execute. In a real project, this would involve test frameworks like Jest or Mocha, but this demonstrates the principle of executing tests.

Run it to see a simulated test result:

console.log("Running automated tests...");
const allTestsPass = Math.random() > 0.1; // Simulate 90% chance of passing

if (allTestsPass) {
  console.log("All 12 tests passed successfully!");
} else {
  console.error("Tests failed! Please fix the errors.");
  process.exit(1); // Exit with a non-zero code to indicate failure
}

Introducing Continuous Deployment (CD)

While CI focuses on building and testing, Continuous Deployment (CD) goes a step further by automatically deploying your application to a server or cloud service once all CI checks pass.

Common CD triggers include:

  • Creating a new Git tag (e.g., v1.0.0)
  • Pushing to a specific branch (e.g., main or production)
  • Creating a GitHub Release

A Simple CD Workflow

Here's a workflow that triggers on a new Git tag and includes a mock deployment step. In a real scenario, this step would interact with your hosting provider (e.g., AWS, Azure, Heroku).

Save this as .github/workflows/cd.yml:

name: Deploy to Production

on:
  push:
    tags:
      - 'v*.*.*' # Triggers on tags like v1.0.0, v1.2.3

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Simulate deployment
        run: |
          echo "Deploying application to production server..."
          echo "Version: ${{ github.ref_name }}"
          echo "Deployment complete!"
          # In a real scenario, you'd use a deployment action here
          # e.g., aws-actions/configure-aws-credentials, appleboy/ssh-action

CI/CD Workflow Check

Which of the following are key benefits of implementing CI/CD pipelines?

Recap: Building CI/CD

You've learned how to build robust CI/CD workflows with GitHub Actions!

  • We defined CI/CD and its benefits for modern development.
  • We explored the essential GitHub Actions workflow YAML structure.
  • We created CI workflows for automating project builds and tests.
  • We designed a CD workflow for automated deployments triggered by tags.

Keep automating to ship code faster and with more confidence!

Frequently asked questions

Is the “Building CI/CD Workflows” lesson free?

Yes — the full text of “Building CI/CD Workflows” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Building CI/CD Workflows”?

Create practical CI/CD pipelines to automatically build, test, and deploy your code upon pushes or pull requests. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Building CI/CD Workflows” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to GitHub Actions
  2. Building CI/CD Workflows
  3. Custom Actions & Marketplace
  4. Secrets and Environment Variables in Actions
← Back to DevOps Bootcamp