All jobs

Add GitHub Actions CI to a Phoenix App

Yes. An agent adds a workflow that compiles with warnings as errors, checks formatting and runs mix test against Postgres on every push and PR of your Phoenix app.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads what the app needs to build and test before it writes a workflow, because a Phoenix suite that passes on a laptop usually depends on a database, a few system packages and versions nobody wrote down. In an app like fly-apps/live_beats there is no .github directory at all. mix.exs declares Elixir ~> 1.12 and a test alias that runs ecto.create --quiet, ecto.migrate --quiet and then test. config/test.exs points LiveBeats.Repo at localhost with the postgres user and password and a database named live_beats_test plus whatever MIX_TEST_PARTITION holds, pool size 10. The Dockerfile pins hexpm/elixir:1.14.0-erlang-24.0.1-debian-bullseye-20210902-slim for the build stage and installs build-essential, git, curl and ffmpeg before mix deps.get.

Three dependencies shape the job more than the rest. phoenix_live_view and bumblebee come from GitHub rather than Hex, so a cache keyed only on mix.lock must include the git checkouts under deps/. exla fetches a precompiled XLA archive on first compile, which is slow and worth caching. And lib/live_beats/application.ex loads openai/whisper-tiny through Bumblebee.load_model inside start/2 whenever the FLAME backend is not FLAME.FlyBackend, which is the case in test, so the suite needs network access to Hugging Face on the first run and a cached BUMBLEBEE_CACHE_DIR afterwards.

The agent writes .github/workflows/ci.yml with push to the default branch and pull_request as triggers. One job sets up Erlang and Elixir with erlef/setup-beam, starting from the 1.14.0 and 24.0.1 pair in the Dockerfile and moving up only if mix deps.get reports a dependency that wants a newer Elixir, with the reason noted in the pull request. A postgres service container with POSTGRES_PASSWORD: postgres and a pg_isready health check matches config/test.exs without touching it. Steps install ffmpeg, restore caches for deps, _build and the Bumblebee cache directory, then run mix deps.get, mix compile --warnings-as-errors, mix format --check-formatted using the .formatter.exs that imports :ecto and :phoenix and loads Phoenix.LiveView.HTMLFormatter, and mix test. The agent also checks whether config/config.exs or config/test.exs reads the LIVE_BEATS_GITHUB_CLIENT_ID and LIVE_BEATS_GITHUB_CLIENT_SECRET variables that config/runtime.exs fetches for production, and sets placeholder values in the workflow env only if a compile-time read needs them.

Before opening the pull request the agent runs the same sequence in its own sandbox against a Postgres it starts there, with the same environment variables the workflow sets, so the first workflow run on GitHub is not the first time the commands meet this repository. It leaves fly.toml and the rel/ release files alone: a deploy job would need a FLY_API_TOKEN secret the agent cannot add, and the brief is CI, not CD.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "codex",
  "input": "Add GitHub Actions CI to this Phoenix app and open a pull request. Read mix.exs, mix.lock, Dockerfile, config/config.exs, config/test.exs, config/runtime.exs, .formatter.exs, test/test_helper.exs and lib/live_beats/application.ex first. Write .github/workflows/ci.yml that runs on push to the default branch and on pull requests, sets up Erlang and Elixir with erlef/setup-beam at versions compatible with the Dockerfile and every dependency, starts a Postgres service matching config/test.exs, installs ffmpeg, caches deps, _build and the Bumblebee model cache, and runs mix deps.get, mix compile --warnings-as-errors, mix format --check-formatted and mix test. Set any environment variable the config reads at compile time. Run the same steps in the sandbox against Postgres before you push and put the output in the pull request description. Do not add a deploy job.",
  "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 nothing else; a placeholder value appears in the workflow's env only when a compile-time read needs it. The description lists the Erlang and Elixir versions it chose and where each came from, the service container, the three caches and their keys, and the exact commands in order. Because the workflow triggers on pull_request, the pull request itself shows the job's first result as a check.

The run's record keeps the sandbox rehearsal: mix deps.get with the GitHub dependencies, the exla compile, the Bumblebee download during application start, and the mix test summary. A reviewer reads it to see which step is slow and whether the caches are keyed on the right files.

Before merging, a reviewer checks that the postgres service credentials match config/test.exs, that the cache paths include deps/ so the git checkouts of phoenix_live_view and bumblebee are reused, and that no secret value was written into the workflow where a placeholder was enough.

Run it on every Phoenix repository without a test workflow

A script on your server lists repositories through GET /o/{org}/github, checks each for a mix.exs that depends on phoenix and for a workflow under .github/workflows that runs mix test, and sends one POST /o/{org}/sessions with this prompt and the repository in resources for every one that has none. Each run reads its own Dockerfile, config and dependency list, so an app that pins a different Elixir or needs ffmpeg or a model download gets a workflow that fits it, and each opens its own pull request.

The key's webhook_url receives run.completed when each turn ends, with data.session_url for reading the pull request link and the rehearsal output.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Phoenix CI goes red for setup reasons more often than code reasons: an Elixir version a dependency rejects, a database the suite expects on localhost, a model download the application makes at boot. The sandbox runs the whole sequence against a real Postgres before anything is pushed, and keeps the output, so the workflow in the pull request has already passed once in an environment the reviewer can read.

One run reads the Dockerfile, the config for every environment and the dependency list, and turns them into a workflow with its caches keyed on the right files. The same prompt runs against every Phoenix repository in the org at once, each in its own sandbox, instead of one engineer copying a workflow between repositories and fixing each one in review.

Frequently asked questions

Which Erlang and Elixir versions does the workflow use?

The agent starts from the pair the Dockerfile pins, 1.14.0 on OTP 24.0.1, and raises them only when mix deps.get or mix compile reports a dependency that needs more. The pull request description names the final pair and the dependency that forced any change, so the versions are traceable rather than guessed.

Why does the suite download a model in CI?

LiveBeats.Application.start/2 loads openai/whisper-tiny with Bumblebee whenever the FLAME backend is not Fly, which includes the test environment. The workflow caches the directory BUMBLEBEE_CACHE_DIR points at, so only the first run on a fresh cache key fetches it.

Does it need any repository secrets?

No. The Postgres service uses the postgres password that config/test.exs already expects, and the GitHub OAuth variables config/runtime.exs reads are only fetched for prod. If a compile-time read needs a value, the workflow sets a placeholder in env, never a real credential.

Can it also deploy to Fly after tests pass?

Not in this run. A deploy job needs a FLY_API_TOKEN secret that only a person can add to the repository, and the prompt asks for CI only. With that secret in place, a follow-up through POST /o/{org}/sessions/{id}/messages can add a job that runs after test on the default branch.

More Phoenix jobs

The same job on other stacks

Keep reading