What the agent does
The agent reads what the tests need before it writes a workflow, because in a repository like lukas-andre/bun-elysia-clean-architecture-example the tests are integration tests against a real database. package.json has no test script at all ("test": "echo \"Error: no test specified\" && exit 1"), db:up starts postgres:14 through docker-compose --env-file .env -f db/docker-compose.yml, db:migrate runs bun migrate.js, and lint runs eslint . --fix. The lockfile is a binary bun.lockb that resolves elysia (declared as latest) to 1.1.12, postgres 3.4.4, @elysiajs/swagger 1.1.1, logixlysia 3.6.1 and bun-types 1.1.26. The repository pins no Bun version: there is no .bun-version and no packageManager field.
The two files under test/ build an Elysia app in beforeAll and drive it with app.handle(new Request(...)), but UserRepository and NoteRepository run real SQL through src/shared/infrastructure/db.ts, which opens postgres(DATABASE_URL) from the PG* variables that src/shared/infrastructure/env.ts parses with zod. Those variables live in a committed .env: PGHOST=localhost, PGPORT=6543, PGDATABASE=notes_api, PGUSER=notes_user, PGPASSWORD=notes_password, PGCONNECT_TIMEOUT=30, plus the POSTGRES_* trio the compose file maps into the container. Bun loads .env on its own, so with no database listening on 6543 bun test reports connect ECONNREFUSED 127.0.0.1:6543 and every test fails. db/schema.sql needs the pgcrypto extension (its hash_password function calls crypt and gen_salt), creates users, notes, tags and note_tags, and installs a trigger that fills notes.search_vector for full-text search.
The sandbox has no Docker, so the agent installs PostgreSQL from apt, creates the role and database the .env names, loads the schema with bun migrate.js and runs bun test against it: both files pass, and a second run against the same database passes too, because user.test.ts deletes testuser before registering it. It also checks what a workflow can and cannot run: bun install --frozen-lockfile reports no changes against the committed bun.lockb, while a plain bun install with a current Bun rewrote that lockfile, so the workflow uses the frozen form. bun x tsc --noEmit fails with five TS2307 errors inside node_modules/logixlysia/src/index.ts, whose own imports use a ~/ alias, so a type-check step is left out and the finding goes in the pull request instead.
The workflow it writes, .github/workflows/ci.yml, runs on push and pull_request, checks out with actions/checkout, installs Bun with oven-sh/setup-bun pinned to one version, and declares a postgres:14 service container with POSTGRES_DB, POSTGRES_USER and POSTGRES_PASSWORD taken from the committed .env, port 6543:5432 so the committed PGPORT works unchanged, and a pg_isready health check. Steps run bun install --frozen-lockfile, bun migrate.js to load db/schema.sql, bun test, and bun x eslint . without --fix, since a lint step that rewrites files proves nothing on a runner. The agent does not add a docker build step: Dockerfile ends in CMD ["bun", "src/index.ts"], and src/ has app.ts but no index.ts, so the image would build and then fail to start.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Add GitHub Actions CI to this Bun and Elysia app. Read package.json, bun.lockb (through bun install --frozen-lockfile), .env, db/docker-compose.yml, db/schema.sql, migrate.js, src/shared/infrastructure/env.ts, src/shared/infrastructure/db.ts, the two files under test/, eslint.config.mjs, tsconfig.json and Dockerfile first. The tests need a real Postgres: install PostgreSQL in your sandbox, create the role and database .env names, load db/schema.sql with bun migrate.js, and run bun test until it passes. Then write .github/workflows/ci.yml that runs on push and pull_request with a postgres:14 service container whose credentials and host port match the committed .env, installs Bun with oven-sh/setup-bun pinned to one version, runs bun install --frozen-lockfile, bun migrate.js, bun test, and eslint without --fix. Try bun x tsc --noEmit and docker build too; if either fails for a reason that is not the workflow's to fix, leave it out and explain why in the pull request. Open a pull request that pastes the test output from your sandbox.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request that adds .github/workflows/ci.yml and changes nothing else: no edit to package.json, to the committed .env or to the tests. The description pastes the bun test output from the sandbox, where the two test files pass against a PostgreSQL the agent installed and migrated, and the bun install --frozen-lockfile line that confirms the lockfile was left as committed.
The description also lists what the workflow deliberately omits and why: no type-check step, because tsc --noEmit fails inside node_modules/logixlysia and not in this code; no image build, because the Dockerfile starts src/index.ts, a file that does not exist; and no bun run lint, because that script passes --fix. Each is a one-line finding the reviewer can turn into a follow-up.
Before merging, a reviewer checks that the service container's POSTGRES_* values and the 6543:5432 port mapping agree with .env, since the tests read that file and not the workflow, picks the Bun version to pin if the agent's choice is not the one the team runs, and reads the first run of the workflow on the pull request itself.
Run it on every repository without a workflow
A team with several Bun services sends one POST /o/{org}/sessions per repository from a terminal or a short script, with this prompt and the repository in resources, and a request_id that is a UUID v5 of the repository's full name, so a retried call returns the run already started instead of a second one. GET /o/{org}/github lists every repository the Rush GitHub App reaches, so the script can start a run only where .github/workflows/ is missing.
Each run opens at most one pull request on its own branch. A key starts at most max_concurrent runs at once (default 4), and a run past that answers 202 with status: "queued" and starts when a slot frees, so a loop over twenty repositories needs no retry logic.
The use case this job follows, with its automation and trigger: Hand off a long task.
Why run it on Rush?
A workflow for an app whose tests need a database is only right once it has run against that database: the service container's credentials, the host port the tests dial and the schema load all have to line up with files the workflow does not own. On a laptop that means Docker, a free port and a few failed pushes to find out. The agent installs PostgreSQL in its own sandbox, loads db/schema.sql, runs bun test and reads the result before it writes a line of YAML, and it tries the steps it is tempted to add (tsc, docker build) so the workflow ships without a step that fails for a reason outside the pull request.
Every command and its output stays on the run, so a reviewer reads the passing test log and the frozen-lockfile check without checking out the branch. Several Bun repositories can get the same workflow at once, each in its own sandbox with its own database, and a step the agent could not make pass is reported, not quietly dropped.
Frequently asked questions
Does the agent need Docker to run the tests?
No. The sandbox has no Docker, so the agent installs PostgreSQL from apt, creates the notes_user role and notes_api database that .env names, and runs bun migrate.js to load db/schema.sql. On GitHub the same database comes from a postgres:14 service container, which the runner starts for you; nothing in the workflow calls docker or db/docker-compose.yml.
Why does the service container map port 6543?
Because the committed .env sets PGPORT=6543, Bun loads that file on its own, and src/shared/infrastructure/env.ts builds DATABASE_URL from it. Mapping 6543:5432 on the service means the tests connect without any change to .env or to the code. Without a database on that port, bun test fails every test with ECONNREFUSED 127.0.0.1:6543.
Why is there no type-check step?
bun x tsc --noEmit fails with TS2307 errors in node_modules/logixlysia/src/index.ts, whose imports use a ~/ alias the package does not resolve for consumers. Narrowing include in tsconfig.json to src and test does not help, because src/app.ts imports the package. The agent reports this in the pull request rather than adding a step that would be red on its first run.
Will bun install change the lockfile on the runner?
Not with --frozen-lockfile, which the workflow uses and which reports no changes against the committed bun.lockb. A plain bun install with a current Bun rewrote that lockfile in the sandbox, which is why the frozen form matters: the workflow should install what the lock says, not update it.
Does the workflow build the Dockerfile?
No. Dockerfile copies src/ and runs CMD ["bun", "src/index.ts"], but the entry point is src/app.ts and src/index.ts does not exist, so the image builds and then fails to start. The agent names this in the pull request as a bug for a separate fix rather than adding a build step that would pass and prove nothing.
The same job on other stacks
- Set Up GitHub Actions CI and Deploys for a Cloudflare Worker (Cloudflare Workers)
- Add GitHub Actions CI to a CMake Project (CMake)
- Set Up GitHub Actions CI for a CodeIgniter 4 App (CodeIgniter)
- Set Up GitHub Actions CI for a Dagster Project (Dagster)
- Add a GitHub Actions CI Job That Runs dbt build on Every Pull Request (dbt)
- Set Up GitHub Actions CI for an Eleventy Site (Eleventy)