Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
# Keeps the npm packages and the SHA-pinned actions in .github/workflows
# current. Each ecosystem gets at most one PR a month, with every update grouped
# into it. A release is only proposed once it is 7 days old, so a compromised
# one has time to be found and pulled.
# Keeps the npm packages and the SHA-pinned actions in .github/workflows current.
#
# Version updates arrive at most monthly, and only for releases at least 7 days old, so a
# compromised release has time to be found and pulled. Minor and patch updates are grouped into
# one catch-all PR per ecosystem, and majors open as their own PRs. Dependabot reads the second
# number of a 0.x version as the minor, so a breaking 0.x release (satori, sharp, @lhci/cli,
# rehype-pretty-code) still lands in the catch-all. Packages that only work at matching versions
# are the exception, in groups of their own that take majors too. Security updates ignore the
# version-update groups and would open one PR per package, so npm's get their own group. It takes
# every update type, because Dependabot judges the type from a package's newest release rather
# than its fix (SemverGroupingRules in dependabot-core), and a narrower group would split off patch
# fixes. The cost is that a breaking fix can hold up the others in that PR. Security updates skip
# the cooldown and the coupled groups, so a fix moves only the package it patches, and a coupled
# package left behind is bumped by hand in the same PR.
# GitHub raises no security alerts for actions pinned to a SHA, so there is no security-update group
# for them, and fixes to actions arrive as version updates.
version: 2
updates:
- package-ecosystem: github-actions
Expand All @@ -10,24 +22,50 @@ updates:
interval: monthly
cooldown:
default-days: 7
open-pull-requests-limit: 1
open-pull-requests-limit: 5
groups:
# upload-artifact and download-artifact have broken compatibility across majors before (v4
# could not read v3's artifacts), so they arrive together, majors included. Dependabot gives a
# dependency to the first group that matches, so this comes before the catch-all.
artifacts:
applies-to: version-updates
patterns: [actions/upload-artifact, actions/download-artifact]
actions:
patterns:
- '*'
applies-to: version-updates
patterns: ['*']
update-types: [minor, patch]
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
cooldown:
default-days: 7
open-pull-requests-limit: 1
open-pull-requests-limit: 10
# @types/node describes the Node API, so it stays at or below the major in .nvmrc. Raise this
# with .nvmrc.
ignore:
- dependency-name: '@types/node'
versions: ['>=26']
groups:
# Each of these sets is pinned or released in step, so one package moving alone can fail the
# checks. They arrive as one PR each, majors included, for version updates only. Dependabot
# gives a dependency to the first group that matches, so these come before the catch-all.
next:
applies-to: version-updates
patterns: [next, eslint-config-next]
react:
applies-to: version-updates
patterns: [react, react-dom, '@types/react', '@types/react-dom']
tailwind:
applies-to: version-updates
patterns: [tailwindcss, '@tailwindcss/*']
vitest:
applies-to: version-updates
patterns: [vitest, '@vitest/*']
npm:
patterns:
- '*'
# A major version can break the checks and block the whole grouped PR, so
# majors are upgraded deliberately instead.
ignore:
- dependency-name: '*'
update-types: ['version-update:semver-major']
applies-to: version-updates
patterns: ['*']
update-types: [minor, patch]
npm-security:
applies-to: security-updates
patterns: ['*']
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Check

on:
# Rebuilds and deploys origin/main on demand, for publishing Notion content
# that has no corresponding commit here. See `npm run deploy:ci`.
# On main, rebuilds and deploys on demand, for publishing Notion content that
# has no corresponding commit here (see `npm run deploy:ci`). On any other
# branch, runs the slow checks without deploying, which is how a Dependabot
# PR is checked before merging (see build).
workflow_dispatch:
push:
branches: [main]
Expand Down Expand Up @@ -64,17 +66,23 @@ jobs:
- run: npm ci
- run: npm run test:ci

# Slow checks - only run on main or when PR is not draft
# Slow checks - run on main, on runs started by hand, and on PRs that are not
# drafts, except Dependabot's (see build)
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [format, lint, typecheck, test]
# Dependabot PRs get no Actions secrets, so the build can't fetch content.
# Skipping it also skips metadata and lighthouse, which need its output.
# Bumped actions those jobs use first run on main, after the PR is merged.
# To check one before merging, start this workflow on its branch with
# `gh workflow run ci.yml --ref <branch>`. A run started by hand has the
# Actions secrets, so check the releases first, as the Dependency Updates
# section of CLAUDE.md says. Deploy, and so wrangler-action, still runs
# only on main.
if: |
github.ref == 'refs/heads/main' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.user.login != 'dependabot[bot]')
Expand Down Expand Up @@ -111,6 +119,7 @@ jobs:
needs: build
if: |
github.ref == 'refs/heads/main' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.draft == false)
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
Expand All @@ -131,6 +140,7 @@ jobs:
needs: build
if: |
github.ref == 'refs/heads/main' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.draft == false)
env:
LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
Expand Down
20 changes: 20 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ const svg = await satori(

This rule ensures the codebase maintains full type safety and prevents runtime errors that `any` would hide.

## Dependency Updates

**A Dependabot PR is merged only after the Check workflow, started by hand on its branch, passes
Build, Metadata and Lighthouse at the commit being merged.** CI skips those jobs on Dependabot PRs,
because GitHub gives Dependabot no Actions secrets and the build fetches content with them. An
update that breaks them would pass CI, and merging it would break `main` and every
`npm run deploy:ci` until it is fixed. Dependabot rebases its branches, so a run of an earlier
commit does not count.

The run gives the new code the build's secrets, and security updates skip the 7-day cooldown, so
check each release the PR adopts for signs of a compromised publish before starting it: a new
publisher, new install scripts, new dependencies, provenance the previous release had and this one
lacks, or a publish only hours old. Then run `gh workflow run ci.yml --ref <branch>` and read the
result with
`gh run list --workflow ci.yml --branch <branch> --event workflow_dispatch --json headSha,conclusion`,
and the run counts only when Build, Metadata and Lighthouse succeeded, not skipped. A branch opened
before this rule has the old `ci.yml`, which skips those jobs even when started by hand, so comment
`@dependabot rebase` on it first. `cloudflare/wrangler-action` runs only in Deploy, so a bump to it
first runs on `main`.

## Publishing and Deploying

Blog posts live in Notion, not in this repo. `next.config.ts` sets `output: 'export'`, so the
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ My personal site where I write about what I'm learning and building πŸ“. It's a
- **✨ Result types for errors** - Rust-style `Result<T, E>` instead of exceptions. Errors are values that flow through function signatures, making error handling explicit
- **πŸ§ͺ Testable by design** - Dependency injection separates I/O from business logic, so tests can validate transformations without mocking modules
- **βœ… Post-build validation** - Scripts parse the actual build output to validate OpenGraph tags, image dimensions, alt text, and SEO metadata. Builds fail if Cloudinary images are missing alt text.
- **⚑ Smart CI pipeline** - Fast checks (format/lint/typecheck/test) run on every commit. Slow checks (build/Lighthouse/metadata) only run when PRs are ready. Lighthouse tests a randomized sample of URLs from the RSS feed instead of only hardcoded paths
- **⚑ Smart CI pipeline** - Fast checks (format/lint/typecheck/test) run on every commit. Slow checks (build/Lighthouse/metadata) only run when PRs are ready, and on Dependabot's PRs only when started by hand, since Dependabot gets no Actions secrets. Lighthouse tests a randomized sample of URLs from the RSS feed instead of only hardcoded paths
- **πŸ”„ Retry with backoff** - All external API calls are wrapped with exponential backoff retry logic to handle transient failures
- **πŸ’Ύ Development caching** - First fetch hits real APIs, then results are cached locally by namespace. Zero network calls on page refresh during development
- **πŸ–ΌοΈ Responsive images** - Cloudinary integration generates srcsets with 9 sizes, automatic format/quality optimization, and enforced alt text
Expand Down
3 changes: 2 additions & 1 deletion io/cloudflare/deploy-via-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ fail() {
exit 1
}

# Runs are also dispatched on Dependabot branches to check them, so only main's count.
latest_dispatch_run_id() {
gh run list --workflow="$WORKFLOW" --event=workflow_dispatch --limit=1 --json databaseId --jq '.[0].databaseId // ""'
gh run list --workflow="$WORKFLOW" --branch="$BRANCH" --event=workflow_dispatch --limit=1 --json databaseId --jq '.[0].databaseId // ""'
}

if ! command -v gh >/dev/null 2>&1; then
Expand Down
Loading