Continuous Integration in CI/CD

This section turns you from someone who reads pipelines into someone who writes and runs them well.

  • Write a pipeline from a blank file.
  • Read red builds and fix them fast.
  • Add lint, type check and test gates, and lock the merge button.
  • Publish test reports, give tests a database, and pass values between jobs.
  • Cut a slow pipeline to under 5 minutes.
  • Save versioned artifacts and build only once.
  • Build, scan and push a container image tagged with the commit.
  • Close the four common attack paths in GitHub Actions.

Every lab runs your real YAML in the browser, for React + TypeScript or ASP.NET Core, on GitHub Actions or Azure Pipelines.

Lessons in this section

  1. Your First Pipeline

    Write a pipeline file yourself: triggers for push, pull request, schedule and manual runs, the setup step for the right version, and jobs that run in order on fresh runners.

    • Write push, pull request, schedule and manual triggers
    • Read a cron schedule
    • Use a setup action to pick the tool version
    • Split work into jobs and set their order
  2. Reading Red Builds

    Read a failed run in five steps and fix the failures you meet at work: wrong tool version, a missing setting, a missing install, a time limit and a lint rule. Tell flaky tests from broken ones.

    • Read a failed log in five steps
    • Tell code problems from pipeline problems
    • Fix version, setting, install and time limit failures
    • Tell flaky tests from broken tests
  3. Quality Gates on Pull Requests

    Add lint, type check and test gates, give each its own job, lock the merge button with branch protection, and stop AI agent pull requests from hiding failures.

    • Add lint and type check steps
    • Split gates into one job each
    • Require checks with branch protection
    • Spot and remove continue-on-error on gates
  4. Tests and Workflow Logic

    Show test failures on the pull request, run tests against a real database, pass values between jobs, and skip runs for docs-only changes.

    • Publish a test report that shows the failing test
    • Run a step even after a failure
    • Give tests a database with a service container
    • Pass a value from one job to the next
  5. Faster Pipelines

    Take a pipeline from about 11 minutes to under 5 with the same checks: cache packages, run checks as parallel jobs, test several versions with a matrix and cancel stale runs.

    • Cache packages with a key from the lock file
    • Run independent checks as parallel jobs
    • Find the critical path on a timeline
    • Test several versions with a matrix
  6. Artifacts and Versions

    Save the build output as a versioned artifact, pass it to the next job, and deploy the same tested artifact to staging and production. Never rebuild after tests.

    • Save the right folder as an artifact
    • Name artifacts with a commit SHA or build number
    • Pass an artifact between jobs
    • Promote one build to staging and production
  7. Containers in CI

    Write a small multi-stage Dockerfile, build and push the image from the pipeline, tag it with the commit, cache layers, scan it with Trivy, and record where it came from.

    • Write a multi-stage Dockerfile
    • Order layers for fast rebuilds
    • Run the app as a non-root user
    • Build and push an image tagged with the commit
  8. Pipeline Security

    Close four attack paths in GitHub Actions: pin actions to commit SHAs, use a read-only token, keep fork code away from secrets, and stop checkout leaving the token on disk. With the Azure Pipelines equivalents.

    • Explain how a tag swap attack works
    • Pin actions to full commit SHAs
    • Set least-privilege token permissions
    • Keep fork pull requests away from secrets