# Update the GitHub Actions in a Node.js Repository's Workflows

Yes. Each week an agent moves your Node.js workflows to current actions pinned by commit, refreshes the Node matrix to supported lines, runs what it can, opens a PR.

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

## What the agent does

The agent reads every workflow and the files they depend on before it bumps anything, because an old workflow usually encodes assumptions that a version bump alone would break. In a repository like OWASP/NodeGoat, `.github/workflows/e2e-test.yml` uses `actions/checkout@v2` with `persist-credentials: false`, `actions/setup-node@v1`, `actions/cache@v2` keyed on `package-lock.json`, and `actions/upload-artifact@v2` for Cypress screenshots on failure, across a matrix of Node `10.x`, `12.x` and `14.x`. It starts MongoDB with `docker run -d -p 27017:27017 mongo:4.0`, waits for the port with `nc` in a loop, runs `npm start` in the background and then `npm run test:ci`, which is `cypress run` from `cypress` 3.3.1. `lint.yml` uses the same two actions and runs `npx --no-install jshint@2.12.0 .`. `.travis.yml` still lists Node 8 to 12 for a CI that no longer runs, the `Dockerfile` builds on `node:12-alpine`, and `docker-compose.yml` uses `mongo:4.4`.

For each `uses:` it looks up the current release with `gh api repos/<owner>/<repo>/releases/latest` and rewrites the line as `@<sha> # vX.Y.Z`, the pin form that Dependabot can keep updated, then reads each major's release notes for behaviour that changed: `actions/setup-node` since v4 caches npm itself through `cache: npm`, so the separate `actions/cache` step goes; `actions/upload-artifact` v4 names artifacts per matrix job and refuses duplicates, which the existing `cypress-artifacts-node<version>` name already satisfies; `actions/checkout` keeps `persist-credentials`. The `docker run` and `nc` loop become a `services:` container for `mongo:4.4`, matching `docker-compose.yml`, with a health check the job waits on, so the workflow stops managing a daemon by hand.

The matrix is the judgement call, and the agent makes it from evidence rather than from the calendar. Node 10, 12 and 14 are past end of life, but `cypress` 3.3.1 and `mongodb` 2 are old enough that a newer runtime might not install them. In its sandbox it runs `npm ci` and `npx cypress verify` on each candidate line, starting with the current LTS releases, keeps the lines that install cleanly, and records the ones that fail with the error, so the pull request proposes a matrix the repository can actually run and says what blocked the rest. It leaves `.travis.yml` and the `Dockerfile` alone and lists them in the description as the next things to retire.

It validates both files with `actionlint`, runs the lint job's command and `npm test` locally, and leaves the Cypress job to the pull request's own checks, since a browser suite against a running app is what the workflow exists to prove. The pull request opens only when `actionlint` is clean and the local commands pass; otherwise the run ends in `needs_review` with the output that stopped it.

## Start it with one API call

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

```json
{
  "agent": "codex",
  "input": "Update the GitHub Actions used by this Node.js repository's workflows. Read every file under .github/workflows, package.json, package-lock.json, docker-compose.yml and the Dockerfile first. Move each action to its current release pinned by commit SHA with a version comment, apply what the new majors changed, such as setup-node's built-in npm cache, replace the hand-started MongoDB container with a service container matching docker-compose.yml, and propose a Node matrix of supported lines that the dependencies actually install on, testing each candidate with npm ci and cypress verify and reporting the ones that fail. Run actionlint, the lint command and npm test. Open a pull request listing every change with its reason, or stop and say why if the jobs cannot pass.",
  "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 on its own branch changing the two workflow files: every action pinned by SHA with its version in a comment, the npm cache folded into `setup-node`, a `services:` block for MongoDB with a health check, the matrix rewritten to the lines that installed, and the artifact step on an action that still runs. No application code, no `package.json` and no lockfile change.

The description has one row per action with the old reference, the new SHA and version, and the note from the release that mattered, followed by the matrix table: each Node line tried, whether `npm ci` and `cypress verify` passed, and the error for the ones that did not. It ends with the two files it did not touch, `.travis.yml` and the `Dockerfile`, and why they deserve their own change.

Before merging, a reviewer confirms each SHA against the tag in its comment, reads the matrix table against the versions the app supports in production, and watches the Cypress job run once on the pull request, since that is the check the sandbox could not perform.

## Run it on every Monday morning

An automation in the Project with a `schedule` trigger, `cron` set to `0 9 * * 1` in your `timezone`, starts one run a week with this prompt and the Project's repository; the trigger puts the slot that fired it after the prompt and fills in no placeholder, and an automation's runs are capped by its own `max_runs_per_hour`. A week with nothing to update ends with a result that says so and no pull request.

A week where a new major changes an input, such as a renamed option on `setup-node`, ends in a pull request that explains the change or in `needs_review` with the failing output, so a human looks only when the weekly run could not finish on its own.

## Why run it on Rush?

Bumping action versions by hand is quick and wrong in the same motion: a new major removes an input, an artifact action stops accepting a name, a runtime the matrix still lists is gone. The agent reads each release before it pins, tries each Node line before it proposes it, and writes down what failed, so the pull request is a report as much as a diff.

On Rush the installs, the verifies and the linting run in the agent's own sandbox on every candidate Node line at once, and the transcript keeps the output that justified the matrix, where a reviewer can read it. Many repositories can be updated the same Monday, each by its own run with its own pull request.

## Frequently asked questions

### Why pin by commit SHA rather than a major tag?

A tag can be moved; a commit cannot. Pinning by SHA with the version in a comment gives the workflow an exact action and lets Dependabot or Renovate propose the next bump by reading the comment, so the pin does not freeze the repository on an old version.

### What if the dependencies do not install on current Node?

The agent says so instead of guessing. It tries each line in its sandbox with `npm ci` and `cypress verify`, keeps the lines that pass, and reports the failing ones with their errors, so the matrix in the pull request is one the suite can run on and the blockers are named for a follow-up.

### Does it update the Dockerfile or Travis config?

No. The run is scoped to the workflows under `.github/workflows`. It lists `.travis.yml`, which no longer runs, and the `node:12-alpine` base image in the description as separate changes with their own risks, rather than widening a weekly maintenance pull request.

### Why run MongoDB as a service container?

The old job starts a container with `docker run` and polls the port with `nc`, which the runner's `services:` feature does for it with a health check and cleanup. Using `mongo:4.4` matches `docker-compose.yml`, so CI and local development run the same database version.

## More Node.js jobs

- [Upgrade an Express 4 App to Express 5 in Node.js](https://getrush.ai/run/upgrade-express-5/nodejs/)
- [Upgrade a Node.js App to Node 24](https://getrush.ai/run/upgrade-node-version/nodejs/)
- [Write Unit Tests for a Node.js App](https://getrush.ai/run/write-unit-tests/nodejs/)

## The same job on other stacks

- [Update Pinned GitHub Actions in a Rust Repo](https://getrush.ai/run/update-github-actions/rust/)
- [Update the GitHub Actions in a Rust CLI's Workflows](https://getrush.ai/run/update-github-actions/rust-cli/)
- [Update Pinned GitHub Actions in a Tauri Repo](https://getrush.ai/run/update-github-actions/tauri/)

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