Skip to content
Latchkey

CI/CD for a Bun App with GitHub Actions

Install fast, test, and build your Bun app with the all-in-one toolkit.

Bun is a fast JavaScript runtime with a built-in bundler, test runner, and package manager. This recipe installs with the frozen lockfile, runs bun test, and builds the app for deploy.

What the pipeline does

  • set up Bun with oven-sh/setup-bun
  • install with bun install --frozen-lockfile
  • run tests with bun test
  • build or compile the app
  • deploy a container or binary

The workflow

--frozen-lockfile makes the install reproducible. bun build with --compile produces a single executable; or just run bun test and deploy source.

.github/workflows/ci.yml
name: CI
on:
  push:
    branches: [main]
  pull_request:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2
        with:
          bun-version: latest
      - run: bun install --frozen-lockfile
      - run: bun test
      - run: bun build ./src/index.ts --compile --outfile app
      - uses: actions/upload-artifact@v4
        with:
          name: app
          path: app

Caching and speed

Cache Bun global cache directory (~/.bun/install/cache) with actions/cache keyed on bun.lockb for fast installs. Bun is already fast, so CI is mostly test time; cheaper managed runners such as Latchkey (around 69% cheaper than GitHub-hosted) keep frequent runs inexpensive and auto-retry transient failures.

Deploying

bun build --compile emits a self-contained executable you can run on any matching host with no runtime installed. Or build a container from the oven/bun base image and deploy to Cloud Run, Fly.io, ECS, or Kubernetes.

Key takeaways

  • Use --frozen-lockfile for reproducible installs.
  • bun build --compile emits a standalone executable.
  • Cache ~/.bun/install/cache for fast installs.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →