πWhat Is GitHub Actions?
GitHub Actions is a built-in CI/CD platform that runs automated workflows directly from your repository. Every time you push code, open a pull request, or cut a release, it can build, test, and deploy your app, no separate CI server needed. It's the most popular CI/CD tool in 2026. Master it in our Git & GitHub Actions course.
πThe Core Concepts
.github/workflows/push, pull_request, schedule)actions/checkout)πYour First Workflow
Create .github/workflows/ci.yml:
name: CIon: push: branches: [ main ] pull_request: branches: [ main ]jobs: build-and-test: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' cache: maven - name: Build and test run: mvn -B verifyPush this file and GitHub runs it automatically. Green check = passing, red X = failing. That's continuous integration.
πAdding Deployment (CD)
Extend the pipeline to deploy only after tests pass:
deploy: needs: build-and-test # waits for tests to pass runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v4 - name: Deploy to server run: ./deploy.sh env: SSH_KEY: ${{ secrets.SSH_KEY }}The needs keyword creates a dependency, so deploy runs only if the build job succeeds.
πSecrets & Environment Variables
Never hardcode credentials. Store them in Settings β Secrets and variables β Actions, then read them as ${{ secrets.MY_SECRET }}. They're encrypted and masked in logs.
πBuilding & Pushing a Docker Image
- name: Log in to registry uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: push: true tags: myapp:latestπA Matrix Build (Test Across Versions)
strategy: matrix: java: [ 17, 21 ] steps: - uses: actions/setup-java@v4 with: java-version: ${{ matrix.java }} distribution: 'temurin'This runs your tests against multiple Java versions in parallel, great for libraries.
πBest Practices
@v4, not a moving tag) for reproducibilityπCommon Interview Questions
push, pull_request, schedule, or workflow_dispatch (manual).needs.upload-artifact/download-artifact) or job outputs.πWhere This Fits
GitHub Actions is the automation layer on top of Git. If you're still shaky on Git itself, start with the Git commands cheat sheet, then automate everything here. This pairs perfectly with microservices and Spring Boot deployments.
πTry It Now
Add a ci.yml to any repo you own, push, and watch the Actions tab. Seeing that first green check run automatically is the moment CI/CD clicks.