# Update the GitHub Actions in a Cobra CLI's Workflow

Yes. An agent moves the actions in your Cobra CLI's workflow to their current releases, pinned by commit SHA, fixes the Go matrix and the lint step, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/update-github-actions/cobra/). 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 tools it calls before it changes a version, because in a Go CLI the action pins and the Go matrix fail together. In a project like spf13/cobra-cli, `.github/workflows/test.yml` has three jobs: `golangci-lint` on `actions/setup-go@v2` with Go 1.17 and `golangci/golangci-lint-action@v2` at `version: latest`; `test-unix` on a matrix of ubuntu and macOS across Go 1.14 to 1.17 with `actions/checkout@v3.1.0` and `actions/cache@v2` keyed on `go.sum`, installing `richgo` and `gox` with `go install` before `make test build`; and `test-win` on `msys2/setup-msys2@v2` with MinGW's Go. `go.mod` says `go 1.15` with `cobra` v1.6.1 and `viper` v1.12.0. `.golangci.yml` enables `deadcode`, `golint`, `interfacer`, `maligned`, `structcheck`, `varcheck` and `gas`, and `.github/dependabot.yml` already asks for weekly `github-actions` updates, which means the pins it has not moved are the ones it cannot move alone.

The agent resolves each action with `gh api` to its latest release and the commit that tag points at: `actions/checkout` v7.0.1, `actions/setup-go` v7.0.0, `actions/cache` v6.1.0, `golangci/golangci-lint-action` v9.3.0 and `msys2/setup-msys2` v2.33.0 as of the day it runs, and writes each as `uses: owner/action@<sha> # vX.Y.Z` so the version is readable and the pin is immutable. It then reads what each major removed. `setup-go` from v4 on caches the module and build directories itself when `go.sum` is present, so the separate `actions/cache@v2` step and its `restore-keys` go away rather than get bumped. `golangci-lint-action` v9 wants golangci-lint v2, so `version: latest` would run a linter that refuses the v1-style `.golangci.yml` with its deleted linters; the agent pins `version: v2.15.0` and rewrites the config with `golangci-lint migrate`, dropping `deadcode`, `golint`, `interfacer`, `maligned`, `structcheck` and `varcheck` (all removed upstream, their checks now inside `unused` and `staticcheck`) and renaming `gas` to `gosec`.

The Go matrix is the other half. Go 1.14 to 1.17 are out of support and `actions/setup-go@v7` still installs them, so the job would pass while testing versions nobody ships. The agent changes the matrix to the two supported releases, 1.26 and 1.27 as `go.dev/dl` lists them when it runs, and the lint job to `go-version-file: go.mod` with `check-latest: true`. It does not raise the `go 1.15` directive in `go.mod`, because that is a compatibility promise to people who install the generator with an older toolchain, and it notes the choice. `richgo` and `gox` are still installed with `go install ...@latest`, since the `Makefile` calls both; the `case` statement that chose between `@latest` and no version for Go 1.14 and 1.15 is deleted along with those versions.

The agent runs what it can in its sandbox before it opens the pull request: `actionlint` on the workflow, `golangci-lint run -v` at v2.15.0 against the migrated config, `make fmt`, `make test` and `make build` on a current Go, and `zizmor` to check the pins and permissions. It cannot run the Windows job locally, so the pull request says so and points at the checks that run on the pull request itself. The description lists each action with its old tag, new tag and SHA, and names the two behaviour changes, the dropped cache step and the linter migration, separately from the plain bumps.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Update the GitHub Actions in this Cobra CLI repository. Read .github/workflows/test.yml, .github/dependabot.yml, .golangci.yml, Makefile and go.mod first. Resolve each action to its latest release with gh api and pin it by commit SHA with a version comment. Read each major release's notes: drop the separate cache step if setup-go now caches modules itself, and if the golangci-lint action now requires golangci-lint v2, pin that version and migrate .golangci.yml, removing linters v2 deleted. Replace the Go matrix with the currently supported Go releases and use go-version-file for the lint job, but do not raise the go directive in go.mod. Run actionlint, golangci-lint at the pinned version, make fmt, make test and make build in the sandbox, run zizmor on the workflow, then open a pull request that lists every action's old tag, new tag and SHA and names each behaviour change separately from the plain bumps.",
  "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/test.yml` and `.golangci.yml` and nothing else. The description has a table of each action with its old tag, new tag and the SHA it is now pinned to, a paragraph on the removed cache step, a paragraph on the linter migration listing the six linters dropped and the one renamed, the new Go matrix, and the `golangci-lint`, `make test` and `make build` output from the sandbox.

The run's record keeps every `gh api` call that resolved a tag to a commit, the `golangci-lint migrate` run and its diff, and the test and build runs, so a reviewer can check a SHA against the release it claims without leaving the record.

Before merging, a reviewer checks that the Go versions the matrix names are the ones the project means to support, decides whether `go.mod`'s directive should move too, and watches the Windows job on the pull request, which the sandbox could not run. `main.go`, `cmd/` and the golden files under `cmd/testdata` are untouched.

## Run it on every Monday morning

`.github/dependabot.yml` already proposes action bumps weekly, but a bump that needs a config migration or removes a step sits unmerged until a person reads the release notes. A scheduled job on the reader's server sends this request each Monday with the repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name and the ISO week, so a second send in the same week returns the run already started. When every pin is already current and the linter config is already v2, the agent reports that and opens nothing.

A team with several Go CLIs sends one request per repository; each run reads its own workflow, so a repository already on `setup-go@v7` with a v2 `.golangci.yml` gets only the SHA refresh, and one with a `goreleaser` action gets that resolved and pinned the same way.

## Why run it on Rush?

The hard part of an actions update is not editing a tag but knowing what each major release removed: a cache step that `setup-go` made redundant, a lint action whose new default refuses the old config, a Go matrix that quietly tests versions nobody ships. In a Rush sandbox the agent resolves every tag with `gh`, reads the release notes, migrates the linter config with the linter's own tool and runs `make test` and `make build` on the result, so the pull request reflects what the workflow will do and not what the diff looks like.

The `gh api` answers, the migration diff and the test run stay with the run and the pull request cites them. Doing this across a dozen Go repositories at once costs the same attention as one, because each run has its own machine, its own record and its own pull request.

## Frequently asked questions

### Why pin by SHA rather than keep @v7?

A tag can be moved; a commit cannot. Pinning `owner/action@<sha> # v7.0.1` makes the workflow run exactly the code the reviewer looked at, and the comment keeps the version readable for people and for Dependabot, which updates SHA pins and their comments together.

### Why drop the cache step instead of bumping it?

`actions/setup-go` has cached `~/go/pkg/mod` and the build cache itself, keyed on `go.sum`, since v4, so a second `actions/cache` step keyed on the same file saves nothing and doubles the restore time. Bumping it to v6 would be a correct-looking change that makes the job slower.

### What happens to the .golangci.yml linters?

The action's new major runs golangci-lint v2, whose config format changed and which no longer ships `deadcode`, `golint`, `interfacer`, `maligned`, `structcheck` or `varcheck`; their checks live in `unused` and `staticcheck` now, and `gas` became `gosec`. The agent runs `golangci-lint migrate`, keeps every linter that still exists, and shows the before-and-after lint output so a reviewer can see no new warning appeared.

### Does it change go.mod?

No. The `go 1.15` directive is what lets people on older toolchains build the generator, and raising it is a separate decision with a different audience. The matrix tests current Go releases because those are what the runners and the module proxy support today; the directive says the minimum, the matrix says what is checked.

## More Cobra jobs

- [Upgrade Go Modules Weekly for a Cobra CLI](https://getrush.ai/run/upgrade-go-modules/cobra/)
- [Write Unit Tests for a Cobra CLI](https://getrush.ai/run/write-unit-tests/cobra/)
- [Add CodeQL Scanning to a Cobra CLI](https://getrush.ai/run/add-codeql-scanning/cobra/)

## The same job on other stacks

- [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/)
- [Update the GitHub Actions in a Helm Chart Repository](https://getrush.ai/run/update-github-actions/helm/)

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