# Update GitHub Actions in a CMake Project's CI

Yes. An agent replaces retired runner images and old action majors in a CMake project's workflows, keeps the matrix honest, builds and tests, and opens a PR.

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

## What the agent does

The agent clones the repository into its own cloud sandbox and reads every workflow before changing a line. In a project like p-ranav/argparse there are three. `.github/workflows/ci.yml` runs on `pull_request` only, with a seven-entry `toolchain` matrix: `macos-latest-clang`, `macos-12-clang`, `ubuntu-latest-clang`, `ubuntu-latest-gcc`, `windows-2019-msvc`, `windows-latest-msvc` and `windows-latest-clang`. Its `include` block maps `macos-12-clang` to `macos-latest`, so that entry duplicates the first one under a misleading name, and maps `windows-2019-msvc` to the `windows-2019` image, which GitHub has retired. Every job uses `actions/checkout@v2`, configures from the `test/` directory, builds, and runs `./tests` or `./Debug/tests.exe`. `tidy-analysis-stage-01.yml` runs on `ubuntu-20.04`, another retired image, installs `clang-tidy-12`, uses `actions/checkout@v3` with `fetch-depth: 2` and `actions/upload-artifact@v4`, and runs `clang-tidy-diff-12.py` over the pull request diff. `tidy-analysis-stage-02.yml` also runs on `ubuntu-20.04` and uses `actions/github-script@v3.1.0` with `github.actions.listWorkflowRunArtifacts`, a namespace that later majors of that action moved under `github.rest`. There is no `.github/dependabot.yml`, and a `.travis.yml` from an earlier CI remains in the tree.

For each action the agent reads the latest release tag in the sandbox with the GitHub API rather than guessing, then pins `actions/checkout`, `actions/upload-artifact` and `actions/github-script` to their current majors, and rewrites the two `github-script` blocks to `github.rest.actions.listWorkflowRunArtifacts` and `github.rest.actions.downloadArtifact`, which is the one change in this set that is not a version bump. The retired images get real replacements: `windows-2019` becomes `windows-2022` so the matrix still has an older MSVC beside `windows-latest`, `ubuntu-20.04` becomes `ubuntu-24.04` with the `clang-tidy` package that image carries and the matching `clang-tidy-diff` script name, and the `macos-12-clang` entry either maps to an image that exists or is dropped as a duplicate, which the prompt decides. The matrix keeps seven meaningful toolchains instead of seven names.

Two small additions keep the pull request from being needed again: a `.github/dependabot.yml` with the `github-actions` ecosystem on a monthly schedule, and `workflow_dispatch` on `ci.yml` so a maintainer can run the matrix from the Actions tab. The stale `.travis.yml` is removed in the same pull request with a note, since no Travis configuration remains anywhere else.

To check its work the agent runs `actionlint` on the three workflows in the sandbox, then does what the Ubuntu matrix entries do: `cmake -S test -B build` with GCC and again with Clang, `cmake --build build`, and `./build/tests`, so the test executable is shown to build and pass on both compilers after the change. It installs the `clang-tidy` the new Ubuntu image ships and runs the stage-01 diff command against a small diff to show the renamed script still produces `fixes.yml`. It cannot run the macOS or Windows entries and says so in the pull request; those are confirmed by the `CI` check on the pull request itself.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Update the GitHub Actions in this CMake project. Read every file under .github/workflows and .travis.yml first. Pin actions/checkout, actions/upload-artifact and actions/github-script to their current major releases, which you look up rather than assume, and rewrite the github-script calls to the github.rest namespace. Replace the retired windows-2019 and ubuntu-20.04 images with windows-2022 and ubuntu-24.04, use the clang-tidy package and clang-tidy-diff script the new Ubuntu image provides, and drop the macos-12-clang matrix entry because it already runs on macos-latest. Add a dependabot.yml for github-actions on a monthly schedule, add workflow_dispatch to ci.yml, and remove .travis.yml. Run actionlint on the workflows, configure and build the test executable with GCC and Clang and run it, exercise the clang-tidy-diff command against a small diff, and open a pull request that lists each change as old and new.",
  "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/ci.yml`, `tidy-analysis-stage-01.yml` and `tidy-analysis-stage-02.yml`, adds `.github/dependabot.yml` and deletes `.travis.yml`. The description is a table with one row per change, old value and new value, from `actions/checkout@v2` to the pinned current major and from `windows-2019` to `windows-2022`, followed by the `actionlint` output and the test run on each compiler from the sandbox.

The run's record keeps the API call that read each action's latest release and every build and test command with its output, so a reviewer can see where each new version came from and that the suite still passes on GCC and Clang.

Before merging, a reviewer watches the `CI` and `Tidy analysis` checks on the pull request, since those are the macOS and Windows runs the sandbox cannot do, and decides whether `windows-2022` is worth keeping beside `windows-latest` or the matrix should shrink further.

## Run it on every first Monday of the month

A schedule in the console starts this run on the first Monday of each month in the Project that has the repository; the prompt tells the run to compare every `uses:` line and every `runs-on:` image against what GitHub currently publishes, open a pull request when something is outdated or retired, and end with no pull request when nothing is. Dependabot covers the action versions between runs; this run is what catches a retired image, which Dependabot does not watch.

From your own cron, the same work is one `POST /o/{org}/sessions` per repository with this body and the repository in `resources`, with a `request_id` that is a UUID v5 of the repository name and the month so a retried call returns the run already started. A webhook URL on the API key reports `run.completed` with the `session_url` to read the pull request link from.

## Why run it on Rush?

A workflow that still names a retired runner image fails every pull request at once, on the day the image is removed, and the fix is rarely a one-word swap: a new Ubuntu image carries a different `clang-tidy` package, a new `github-script` major moved its API namespace, and a matrix entry that already pointed at the wrong image was hiding a duplicate. The agent reads every workflow, looks up current versions instead of assuming them, and builds and runs the test suite on both Linux compilers before the pull request exists.

The sandbox is its own computer where installing two compilers and a `clang-tidy` costs nothing on anyone's laptop, every lookup and build stays in the run's record, and an organization with many C++ repositories can run the same update across all of them at once, each in its own sandbox with its own pull request.

## Frequently asked questions

### Why not let Dependabot do this?

The pull request adds Dependabot for exactly the version bumps, but Dependabot does not know that a `runs-on` image was retired or that a `github-script` major renamed its API. Those two changes need someone to read the workflow and the release notes, which is what the agent does.

### What happens to the macos-12-clang entry?

Its `include` block already maps it to `macos-latest`, so it ran the same job as `macos-latest-clang` under a name that suggested an older image. The prompt drops it; a reviewer who wants an older macOS in the matrix can add an entry that names an image GitHub still provides.

### Does the run test on Windows and macOS?

No. The sandbox is Linux, so the agent builds and runs the tests with GCC and Clang there and runs `actionlint` over all three workflows. The Windows and macOS entries run as the pull request's own `CI` check, which the reviewer watches before merging.

### Will the clang-tidy job report different findings on the new image?

Possibly, since the image's `clang-tidy` is a newer major than the one the old workflow installed and the project's `.clang-tidy` enables whole check families. The job only reports on the pull request diff, so the first pull requests after the merge show any new checks as review comments rather than failures.

## More CMake jobs

- [Add ccache to a CMake Project's GitHub Actions Builds](https://getrush.ai/run/add-ccache-to-ci/cmake/)
- [Add a clang-format Check to CI for a CMake Project](https://getrush.ai/run/add-clang-format-check/cmake/)
- [Add clang-tidy to a CMake C++ Project and Its CI](https://getrush.ai/run/add-clang-tidy/cmake/)

## The same job on other stacks

- [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/)
- [Update the GitHub Actions in a Gradle Build's Workflow](https://getrush.ai/run/update-github-actions/gradle/)

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