BBackend CourseLeroy Labs
0/0
Search the course

CI/CD with GitHub Actions, path filters, OIDC to AWS & image tagging

Continuous integration vs delivery vs deployment, workflow anatomy, path filters for monorepos, keyless AWS auth with OIDC, tagging images by git SHA, and deploy strategies.

● intermediateReport-Manager-2IR3D (Kontentt)Hostel-Web-App

Definitions

  • CI: every push is built and tested automatically.
  • Continuous Delivery: every green build can be deployed with one click.
  • Continuous Deployment: every green build on main is deployed automatically.

A workflow, annotated

name: backend
on:
  push: { branches: [main] }
  pull_request:

permissions:
  id-token: write        # allow OIDC token for AWS
  contents: read

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs: { backend: ${{ steps.f.outputs.backend }} }
    steps:
      - uses: actions/checkout@v4
      - id: f
        uses: dorny/paths-filter@v3
        with: { filters: "backend: ['hostel-backend/**']" }    # skip if only frontend changed

  test:
    needs: changes
    if: needs.changes.outputs.backend == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-java@v4
        with: { distribution: temurin, java-version: '25', cache: maven }
      - run: ./mvnw -B -ntp verify          # Docker is available, so Testcontainers works

  deploy:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    environment: production                 # can require manual approval
    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with: { role-to-assume: arn:aws:iam::123456789012:role/Deploy, aws-region: eu-west-1 }
      - run: docker build -t $ECR/app:${{ github.sha }} . && docker push $ECR/app:${{ github.sha }}

OIDC: no stored cloud keys

GitHub issues a short-lived signed token saying “this is repo X, branch main”. AWS IAM trusts GitHub’s OIDC provider and lets that token assume a role. No long-lived AWS_ACCESS_KEY_ID is stored in GitHub secrets, so there’s nothing to leak.

In your projects

Hostel-Web-App.github/workflows/deploy.yml

“Build and Deploy to AWS Fargate”: paths-filter on backend changes, OIDC (role-to-assume: ...:role/Hostel-Github-Actions, id-token: write), then npx cdk bootstrap and npx cdk deploy --require-approval never. The infrastructure and app deploy together.

IR3D (Kontentt).github/workflows/backend-deploy.yml · backend-tests.yml

backend-tests.yml runs ./mvnw -B test. The deploy workflow builds an ARM image tagged kontentt-backend:${{ github.sha }}, pushes it to ECR, then deploys with aws ssm send-command, which runs the update script on EC2 without SSH or open ports.

Report-Manager-2Report-Manager-2/.github/workflows/deploy.yml

paths-filter, ./mvnw -B -ntp test, then build and push :latest (main) or :staging. Watchtower on the server polls the registry and restarts containers when the tag’s image changes. As a comment in ResilientPublisher notes, Watchtower “never applies docker-compose changes”, so new env vars or services still need a manual step.

Deployment strategies

Strategy How Downtime / risk
Recreate Stop old, start new Downtime
Rolling (ECS default) Replace instances gradually No downtime; mixed versions briefly
Blue/green Run the new version alongside, switch traffic Instant rollback; 2× resources
Canary Send 5% of traffic to the new version, watch metrics, then increase Safest; needs good metrics
Feature flags Deploy dark, enable later Decouples deploy from release

Hostel’s ECS service has circuit-breaker rollback: if new tasks fail health checks, ECS automatically rolls back.

  • Branch protection. Require green CI and reviews before merging to main.
  • Caching Maven dependencies (cache: maven) for fast CI.
  • Environments and approvals in GitHub for production gates.
  • Dependabot or Renovate for dependency updates.
  • For your course on Render, CI is built in: every push to the repo triggers a Render build and deploy.

Check yourself

1. Benefit of OIDC in GitHub Actions?
2. Best image tag for traceable rollbacks?