🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

CI/CD pipeline with GitHub Actions

Every push runs tests and linting; every merge to main builds an image and deploys automatically.

Intermediate⏱ 6–10 hoursđŸĒœ 7 stepsGitHub ActionsDockerTests

What you'll learn

  • ◆Workflows, jobs and steps
  • ◆Secrets and environments
  • ◆Build caching and deployment strategies

What you'll build

  • ✓Lint and test on every pull request
  • ✓Status badge in README
  • ✓Build and push a Docker image on main
  • ✓Automatic deploy with a manual approval option

Step-by-step guide

  1. 1

    First workflow

    .github/workflows/ci.yml triggered on push and pull_request; checkout, set up the language, install, test.

  2. 2

    Matrix

    Test on two versions (for example Node 20 and 22) with strategy.matrix.

  3. 3

    Cache

    Use the setup action's cache option or actions/cache to speed up installs.

  4. 4

    Build image

    On main, log in to a registry (GitHub Container Registry) with secrets and build/push with docker/build-push-action.

  5. 5

    Deploy

    SSH to a server (key stored in GitHub secrets) and pull + restart, or deploy to a cloud service.

  6. 6

    Protect main

    Branch protection: require CI to pass before merging.

  7. 7

    Document

    Diagram of the pipeline and a badge in the README.

🚀 Make it stand out

  • +Preview deployments for pull requests
  • +Security scanning (dependency audit, CodeQL)
  • +Rollback job