# Update the GitHub Actions in a tRPC Project's CI

Yes. An agent moves your tRPC project's CI off retired action majors, fixes the pnpm steps that need a lockfile and a version, reruns the jobs, and opens a PR.

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

## What the agent does

The agent reads the workflow and the project it builds before it changes a version, because in a pnpm project the action pins and the repository's own files fail together. In a project like trpc/examples-next-prisma-starter, `.github/workflows/main.yml` is named `Testing`, runs on `push` only, and has two jobs, `e2e` and `unit`, each with a `postgres` service. Both check out with `actions/checkout@v3` and `fetch-depth: 0`, install pnpm with `pnpm/action-setup@v5` and no `version` input, set up Node 22 with `actions/setup-node@v3` and `cache: 'pnpm'`, run `pnpm install`, cache `.next/cache` with `actions/cache@v3` keyed on `hashFiles('**/pnpm-lock.yaml')`, and run `pnpm prebuild`; `e2e` then runs `pnpm build`, `pnpm test-e2e` and `pnpm tsc` and uploads `playwright/test-results` with `actions/upload-artifact@v2` under `if: always()`, while `unit` runs `pnpm test-unit` and `pnpm tsc`. `package.json` has no `packageManager` field, and the repository contains no `pnpm-lock.yaml`, `package-lock.json` or `yarn.lock`. `.github/dependabot.yml` watches the `npm` ecosystem daily and nothing else. The scripts behind the jobs are `prebuild` (`prisma generate` and `prisma migrate deploy`), `build` (`next build`), `test-unit` (`vitest`), `test-e2e` (`playwright test`) and `typecheck`.

Three of those lines are not merely old. GitHub deprecated v1 and v2 of `actions/upload-artifact` and `actions/download-artifact` on 2024-06-30 and said a workflow using them after that date fails, so the `e2e` job's upload step fails whenever it runs. `pnpm/action-setup` without a `version` input needs a `packageManager` field in `package.json` to know which pnpm to install, and this `package.json` has none. And `actions/setup-node` with `cache: 'pnpm'` looks for a `pnpm-lock.yaml` to hash and fails the step when there is none, which the workflow's own comment beside that line half admits. The agent reads each action's release notes and resolves the current releases with `gh api`: `actions/checkout` v7.0.1, `actions/setup-node` v7.1.0, `actions/cache` v6.1.0, `actions/upload-artifact` v7.0.2 and `pnpm/action-setup` v6.1.0 as of the day it checks, and writes each `uses:` as the release's commit SHA with the version in a comment, so Dependabot can keep bumping it and a tag move cannot change what runs.

The lockfile is the decision the agent does not make alone. Committing one is a dependency change, not a workflow change, so it keeps `cache: 'pnpm'` and the `.next/cache` key only if a `pnpm-lock.yaml` exists in the repository it runs on, and otherwise removes the `cache` input, keys the Next.js cache on `hashFiles('**/package.json')`, and says in the pull request that committing `pnpm-lock.yaml` is what makes installs reproducible and the cache useful. For pnpm's version it adds a `packageManager` field, `pnpm@<version>`, with the major its sandbox install used, since pnpm itself and Corepack read that field, which keeps local and CI on one version without a second number in the workflow. It adds `pull_request` beside `push` in `on:`, a `permissions: contents: read` block, and a `github-actions` entry to `.github/dependabot.yml` so the pins stay fresh between runs. Artifacts changed shape in v4: each upload is immutable and names must be unique per run, which this workflow already satisfies with one upload step.

Before it opens the pull request the agent runs what the jobs run. It installs PostgreSQL from the system packages, sets `DATABASE_URL` as `.env` and `src/server/env.ts` expect, runs `pnpm install`, `pnpm prebuild`, `pnpm test-unit`, `pnpm tsc` and `pnpm build`, installs Chromium with `pnpm exec playwright install chromium` and runs `pnpm test-e2e` against `next start` as `playwright.config.ts` does under `CI`. It runs `actionlint` on the workflow and `zizmor` for the pins and permissions, and lists in the pull request each action with its old tag, new tag and SHA, separately from the three behaviour fixes.

## Start it with one API call

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

```json
{
  "agent": "codex",
  "input": "Update the GitHub Actions in this project's CI. Read .github/workflows/main.yml, .github/dependabot.yml, package.json, .npmrc, .env, src/server/env.ts, playwright.config.ts and vitest.config.mts first, and check whether a pnpm lockfile is committed. For every uses: line, look up the current release of the action and pin it by the release's commit SHA with the version in a comment. Replace actions/upload-artifact v2, which GitHub deprecated, with the current major. Give pnpm/action-setup a version by adding a packageManager field to package.json with the pnpm major you install in the sandbox. If no pnpm-lock.yaml exists, drop the cache input from setup-node and key the Next.js cache on package.json, and say in the pull request that committing the lockfile is the real fix; if one exists, keep both. Add pull_request to the triggers, a read-only permissions block, and a github-actions ecosystem to dependabot.yml. Start PostgreSQL in the sandbox and run pnpm install, prebuild, test-unit, tsc, build and the Playwright tests, run actionlint and zizmor, and open a pull request that lists each action's old and new version and SHA and the behaviour fixes separately.",
  "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 changes `.github/workflows/main.yml`, `.github/dependabot.yml` and `package.json`. The description has a table with each action's old tag, new tag and pinned SHA, a separate list of the three fixes that change behaviour, the artifact action that had stopped working, the pnpm version source and the cache input, and the output of `actionlint`, `zizmor` and each `pnpm` script it ran in the sandbox.

The run's record keeps the `gh api` lookups, the PostgreSQL start and every script run, so a reviewer can check the SHA of each pin against the release it names and see that `pnpm build` and the Playwright suite ran on the migrated workflow's commands.

Before merging, a reviewer decides whether to commit `pnpm-lock.yaml` in the same pull request or a following one, whether `fetch-depth: 0` is still needed since nothing in the jobs reads history, and whether the `postgres` service image should be pinned to a major as the actions now are. Application code, Prisma schema and tests are unchanged.

## Run it on every Monday morning

From your own cron, this is one `POST /o/{org}/sessions` per repository each Monday with this body and the repository in `resources`, with a `request_id` that is a UUID v5 of the repository's full name and the ISO week, so a retried call in the same week returns the run already started. When every pin is already current and nothing is broken, the run ends with no pull request and says so. A webhook URL on the API key reports `run.completed` with the `session_url` to read the pull request link from.

Dependabot covers plain version bumps between runs once the `github-actions` ecosystem is in `dependabot.yml`; this run is what catches a deprecated action that fails outright, a missing `version` input or a cache step with nothing to hash, which a version bump never fixes.

## Why run it on Rush?

A workflow that was correct when the starter was written fails years later for three unrelated reasons, and only one of them is the version number a bot would bump. The agent reads the actions' release notes and the repository's own files together, so the pull request fixes the deprecated artifact action, the pnpm version and the lockfile-dependent cache in one pass and explains each.

On Rush the lookups, the database, the build and the browser tests run in the run's own sandbox with their output kept, so the pull request carries evidence that the commands the workflow runs still pass. A team with many repositories on the same starter runs one of these per repository and reviews each pull request on its own.

## Frequently asked questions

### Why pin by commit SHA instead of a major tag?

A tag such as `v7` can be moved to point at new code; a commit SHA cannot. Pinning by SHA with the version in a trailing comment keeps the workflow readable, lets Dependabot update both together, and means a compromised or mistaken tag push changes nothing in your CI. The agent resolves each SHA from the release's own tag with `gh api` and records it in the pull request.

### Why did the artifact upload stop working?

GitHub deprecated v1 and v2 of `actions/upload-artifact` and `actions/download-artifact` on 2024-06-30, and a workflow that uses them after that date fails rather than warns. The current line keeps the step, moves it to the latest major and notes that artifacts there are immutable and need unique names per run, which this workflow already has.

### Can Dependabot do this instead?

For version bumps, yes, once `dependabot.yml` lists the `github-actions` ecosystem, which this project's did not. Dependabot does not add a missing `packageManager` field, does not know that `cache: 'pnpm'` needs a lockfile, and does not change triggers or permissions. The run does those once; Dependabot keeps the versions current afterwards.

### What about the missing lockfile?

Without `pnpm-lock.yaml`, `pnpm install` resolves fresh on every run and `setup-node`'s cache has nothing to key on. The agent treats committing a lockfile as a dependency decision for the team and does not make it inside a CI update; it removes the cache input so the workflow runs, and the pull request names the lockfile as the change that makes installs reproducible and the cache useful.

## More tRPC jobs

- [Write Playwright Tests for a tRPC + Next.js App](https://getrush.ai/run/write-playwright-tests/trpc/)
- [Write Vitest Tests for a tRPC Router](https://getrush.ai/run/write-vitest-tests/trpc/)
- [Add API Error Handling to a tRPC App](https://getrush.ai/run/add-api-error-handling/trpc/)

## The same job on other stacks

- [Update GitHub Actions in a CMake Project's CI](https://getrush.ai/run/update-github-actions/cmake/)
- [Update the GitHub Actions in a Cobra CLI's Workflow](https://getrush.ai/run/update-github-actions/cobra/)
- [Upgrade Pinned GitHub Actions to the Latest Releases](https://getrush.ai/run/update-github-actions/github-actions/)

## 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/)
