Skip to Content
Mengty Learns
CI/CD

CI/CD for This Site

How Mengty Learns validates the Next.js static build, tests hands-on labs, and collects weekly RSS inbox items using three GitHub Actions workflows.

how-tointermediateTested with node 22.22.3, pnpm 11.6.0Updated Nov 26, 2026

TL;DR

This repository runs three focused GitHub Actions workflows: ci.yml gates every PR on lint, typecheck, and static build; labs.yml lints and builds labs/** only when lab files or workflows change; and inbox.yml creates a weekly GitHub issue from RSS feeds.

Why it exists

A learning site with real code labs and an RSS reading inbox needs fast feedback without mixing concerns: PRs that edit a Markdown note should not rebuild Docker images, and an automated RSS job should never have write access to repository contents.

Mental model

Each workflow has a single trigger scope and minimal permissions:

WorkflowTriggerWhat it runs
.github/workflows/ci.ymlpush (main, mengtylearns-mvp) & pull_requestpnpm install --frozen-lockfile, lint, typecheck, build
.github/workflows/labs.ymlpush (main) & pull_request on labs/** or labs.ymlhadolint + docker build, tofu fmt/validate + tflint, kubeconform, actionlint
.github/workflows/inbox.ymlWeekly cron: '0 9 * * 1' & workflow_dispatchnode scripts/inbox.mjs → creates/updates "Inbox week $WEEK" issue

Do it

1. Site build gate (ci.yml)

Every push to main or PR runs the exact same three commands we run locally, using pinned pnpm 11.6.0 and Node 22:

# .github/workflows/ci.yml
- uses: pnpm/action-setup@v4
  with:
    version: 11.6.0
- uses: actions/setup-node@v4
  with:
    node-version: 22
    cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm typecheck
- run: pnpm build

You can run the same gate locally before committing:

pnpm lint && pnpm typecheck && pnpm build

2. Path-filtered lab validation (labs.yml)

labs.yml only triggers when labs/** or .github/workflows/labs.yml changes, and drops token permissions to contents: read. Each job (docker, tofu, kubernetes, workflows) checks whether matching files exist before installing tools:

# .github/workflows/labs.yml
- name: Find Dockerfiles
  id: find
  shell: bash
  run: |
    shopt -s nullglob
    files=(labs/*/Dockerfile)
    echo "has_files=$([[ ${#files[@]} -gt 0 ]] && echo true || echo false)" >> "$GITHUB_OUTPUT"

- name: Build Docker images (no push)
  if: steps.find.outputs.has_files == 'true'
  shell: bash
  run: |
    shopt -s nullglob
    for df in labs/*/Dockerfile; do
      dir="$(dirname "$df")"
      name="$(basename "$dir")"
      echo "::group::docker build $dir"
      docker build --no-cache -t "lab-${name}:ci" "$dir"
      echo "::endgroup::"
    done

The tofu job runs tofu fmt -check -recursive labs/, tofu init -backend=false && tofu validate, and tflint; kubernetes runs kubeconform -strict -summary labs/**/k8s/*.yaml; and workflows runs actionlint on .github/workflows/*.yml.

3. Weekly RSS inbox (inbox.yml)

inbox.yml runs every Monday at 09:00 UTC ('0 9 * * 1') with permissions: issues: write. It executes scripts/inbox.mjs and uses gh CLI to open or update one issue per ISO week so nothing is committed or published automatically:

# .github/workflows/inbox.yml
- name: Fetch feeds
  run: node scripts/inbox.mjs --out inbox-report.md

- name: Create or update weekly inbox issue
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    WEEK=$(date +%V)
    TITLE="Inbox week $WEEK"
    EXISTING=$(gh issue list --state open --search "\"$TITLE\" in:title" --json number,title --jq ".[0].number // empty")
    if [ -n "$EXISTING" ]; then
      gh issue edit "$EXISTING" --body-file inbox-report.md
    else
      gh issue create --title "$TITLE" --body-file inbox-report.md
    fi

Gotchas

  • Lockfile drift: ci.yml and inbox.yml both pass --frozen-lockfile; updating package.json without committing pnpm-lock.yaml fails immediately.
  • Unpinned actions vs pinned versions: labs.yml pins actions/checkout@v4.2.2 and hadolint/hadolint-action@v3.5.0, whereas ci.yml uses @v4 tags — prefer full version tags or commit SHAs for supply-chain hardening.
  • labs.yml path filter: If you add a new lab tool that touches files outside labs/**, labs.yml will not trigger unless you update its paths: list.

Production checklist

  • Run pnpm lint && pnpm typecheck && pnpm build locally before pushing.
  • Keep permissions scoped per workflow (contents: read for checks, issues: write for the inbox bot).
  • Pin pnpm and Node versions across all workflows so local and CI builds match.

Check yourself

Check Yourself

1. Why does .github/workflows/labs.yml check has_files before running Docker, OpenTofu, or kubeconform steps?

2. What does .github/workflows/inbox.yml do with the fetched RSS items?

Sources