# Add GitHub Actions CI to a Leptos App

Yes. An agent writes a GitHub Actions workflow for your Leptos and Axum app: fmt and clippy checks, a cargo-leptos build, the Playwright tests, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-github-actions-ci/leptos/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the template the app came from, because a Leptos project generated with `cargo leptos new --git https://github.com/leptos-rs/start-axum` carries choices that decide what CI has to install. `Cargo.toml` depends on `leptos`, `leptos_router`, `leptos_meta` and `leptos_axum` at 0.8.0 and `axum` 0.8.0, with `tokio` and `axum` behind the `ssr` feature and `wasm-bindgen` 0.2.106 behind `hydrate`; the crate is both `cdylib` and `rlib`, and `[package.metadata.leptos]` sets `bin-features = ["ssr"]`, `lib-features = ["hydrate"]`, `style-file = "style/main.scss"`, `site-addr = "127.0.0.1:3000"`, `end2end-dir = "end2end"` and `end2end-cmd = "npx playwright test"`. `rust-toolchain.toml` names the nightly channel, but `cargo-generate.toml` drops that file when the template question about nightly is answered No, so a generated app on stable has no toolchain file. There is no `.github/` directory.

Two files change what the agent does before it writes any YAML. The template's `.gitignore` excludes `Cargo.lock`, with the comment that an executable should remove that line; a web server is an executable and CI without a lockfile builds a different dependency set on every run, so the agent removes the line and commits the lockfile from the sandbox build. And `end2end/playwright.config.ts` has no `webServer` block and lists three projects, chromium, firefox and webkit, with `workers: 1` and `retries: 2` when `CI` is set; the one test in `end2end/tests/example.spec.ts` opens `http://localhost:3000/` and expects the title `Welcome to Leptos` and an `h1` reading `Welcome to Leptos!`. `cargo leptos end-to-end` starts the server itself before running `end2end-cmd`, so no `webServer` is needed, and `end2end/package-lock.json` exists, so `npm ci` works.

`.github/workflows/ci.yml` runs on `push` to `main` and on `pull_request`. A `check` job installs stable Rust with the `wasm32-unknown-unknown` target, restores a cargo cache, and runs `cargo fmt --all --check`, `cargo clippy --features ssr -- -D warnings` for the server and `cargo clippy --lib --features hydrate --target wasm32-unknown-unknown -- -D warnings` for the client, because the two halves compile different code behind their features and a warning in one is invisible to the other. A `build-and-test` job installs `cargo-leptos` as a prebuilt binary through `cargo-binstall` rather than compiling it, installs `sass` since `style/main.scss` needs it, runs `cargo leptos build --release`, sets up Node, runs `npm ci` in `end2end`, installs the three browsers with `npx playwright install --with-deps`, and runs `cargo leptos end-to-end --release`. The Playwright HTML report is uploaded as an artifact on failure.

The agent runs the same sequence in its sandbox first: it adds the wasm target, installs `cargo-leptos` and `sass`, builds, and runs the end-to-end test against the server `cargo-leptos` starts on `127.0.0.1:3000`. If clippy reports anything in the generated code it fixes only what the template itself produced, such as an unused import, and lists each fix in the pull request; it does not touch `src/app.rs` beyond that. The generated lockfile is committed in the same pull request so the first CI run builds exactly what the agent built, and `actionlint` runs on the workflow file.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add GitHub Actions CI to this Leptos application generated from the start-axum template. Read Cargo.toml, .gitignore, rust-toolchain.toml if present, cargo-generate.toml if present, end2end/package.json, end2end/playwright.config.ts, end2end/tests/example.spec.ts, src/main.rs, src/lib.rs and src/app.rs first. Stop ignoring Cargo.lock and commit the lockfile from your build. Write .github/workflows/ci.yml with a check job that installs stable Rust with the wasm32-unknown-unknown target and runs cargo fmt --all --check, cargo clippy with the ssr feature and cargo clippy --lib with the hydrate feature on the wasm target, both with -D warnings, and a build-and-test job that installs cargo-leptos as a prebuilt binary, installs sass, runs cargo leptos build --release, runs npm ci in end2end, installs the Playwright browsers the config lists with --with-deps, runs cargo leptos end-to-end --release, and uploads the Playwright report on failure. Cache cargo. Run every step in the sandbox before writing it; fix only clippy findings in template-generated code and list them. Run actionlint on the workflow and open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **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.
2. **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.
3. **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 `Cargo.lock` and removes one line from `.gitignore`. The description lists the two jobs and their steps, explains why clippy runs twice with different features and targets, why `cargo-leptos` is installed as a binary, and why the lockfile is now committed, and lists any clippy finding the agent fixed in generated code.

The run's record keeps the output of the build and of `cargo leptos end-to-end`, including the Playwright run against the three browsers, so a reviewer sees the one existing test pass before the workflow has run once on GitHub.

Before merging, a reviewer decides whether firefox and webkit belong in CI or whether `--project chromium` is enough for pull requests, whether to add a release job that builds the server binary and `target/site` as deployable artifacts, and whether `-D warnings` on clippy is the right strictness for a project this new.

## Run it on every new repository

A team that generates several apps from the same template runs this once per repository from its own server: one `POST /o/{org}/sessions` per repository, each with that 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 rather than opening a second pull request. Each run builds the WebAssembly bundle and the server in its own sandbox.

Once the workflow is in, an automation on the Project with a `github` trigger on `pull_request.opened` and the prompt "if this pull request adds a route to src/app.rs, add a Playwright test for it under end2end/tests in the style of example.spec.ts and push it to this branch" keeps the end-to-end suite growing with the app. The trigger adds the pull request after the prompt; only work by an owner, member or collaborator fires it, never a fork's.

## Why run it on Rush?

A Leptos build has more moving parts than a plain Rust crate: a second compilation target, a tool that orchestrates both, a Sass compiler and a browser test runner. A workflow written from memory usually fails on the first run for one of them. The agent installs each piece in its own sandbox, runs the exact commands, and writes the workflow from what passed, so the first GitHub run is green or the pull request says what is still missing.

Every command's output stays with the run, including the Playwright results, so a reviewer reads the evidence rather than waiting for the first workflow run to see it. Several apps can be set up at once, each on its own machine with its own record.

## Frequently asked questions

### Why is Cargo.lock suddenly committed?

The template ignores it, with a comment that an executable should stop doing so. A web server is an executable, and CI that resolves dependencies fresh on each run cannot tell a code change from an upstream change. Committing the lockfile the agent built from makes the first CI run reproducible.

### Why run clippy twice?

The server compiles with `ssr` and the client compiles with `hydrate` for `wasm32-unknown-unknown`; code behind one feature is never checked by the other run. Two invocations cover both halves of the crate. Formatting runs once, since `cargo fmt` does not depend on features.

### Does the workflow need nightly Rust?

Only if the project was generated with the nightly option, in which case `rust-toolchain.toml` is present and the toolchain action reads it. The agent checks for the file and uses stable when it is absent, which is the template's default answer.

### Can the browsers be narrowed to speed up CI?

Yes. `end2end-cmd` in `Cargo.toml` is `npx playwright test`; appending `--project chromium` there, or removing projects from `playwright.config.ts`, cuts the install and the run to one browser. The agent keeps the three the config lists and leaves that choice to the reviewer.

## More Leptos jobs

- [Add Graceful Shutdown to a Leptos Axum Server](https://getrush.ai/run/add-graceful-shutdown/leptos/)
- [Add Health Checks to a Leptos App](https://getrush.ai/run/add-health-checks/leptos/)
- [Add i18n to a Leptos App](https://getrush.ai/run/add-i18n/leptos/)

## The same job on other stacks

- [Add GitHub Actions CI to a Lit Web Component Project](https://getrush.ai/run/add-github-actions-ci/lit/)
- [Add GitHub Actions CI to a Medusa Monorepo](https://getrush.ai/run/add-github-actions-ci/medusa/)
- [Set Up GitHub Actions CI for a Next.js App](https://getrush.ai/run/add-github-actions-ci/nextjs/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
