# Add Dependabot to an Echo App

Yes. An agent reads your Echo app's go.mod and workflow, writes a grouped dependabot.yml for Go modules, Actions and Docker, proves the build, and opens a PR.

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

## What the agent does

The agent reads what Dependabot would have to update before it writes a line of configuration. In an API laid out like xesina/golang-echo-realworld-example-app, `go.mod` declares module `github.com/xesina/golang-echo-realworld-example-app` with a `go 1.18` directive and eleven direct requirements: `github.com/labstack/echo/v4 v4.1.16`, `github.com/jinzhu/gorm v1.9.8`, `github.com/dgrijalva/jwt-go v3.2.0+incompatible`, `github.com/gosimple/slug v1.5.0`, `github.com/swaggo/echo-swagger v1.0.0`, `github.com/swaggo/swag v1.6.5`, `github.com/stretchr/testify v1.4.0`, `gopkg.in/go-playground/validator.v9 v9.28.0`, a pseudo-version of `golang.org/x/crypto` from 2020, `github.com/labstack/gommon` and `github.com/alecthomas/template`. `github.com/mattn/go-sqlite3 v1.10.0` is indirect but is the driver `db/db.go` opens through `gorm.Open("sqlite3", "./realworld.db")`, so a bump to it changes the test database too. There is no `.github/dependabot.yml`, and `.github` holds one workflow.

That workflow, `.github/workflows/go.yml`, is the second thing the agent reads, because a `github-actions` entry only helps when the references are version tags. It runs on every push and pull request with `actions/checkout@v3` and `actions/setup-go@v3` pinned to `go-version: 1.18`, then `go build -v ./...` and `go test -v ./...`. The `Makefile` runs the same tests with `-race`. The `Dockerfile` builds on `golang:1.12.1` and ships on an untagged `alpine`, which a `docker` entry would track: the first image is older than the module's own `go` directive and the second has no version to bump, and the agent says both in the pull request rather than silently changing the image.

The agent then writes `.github/dependabot.yml` with three `updates` entries. The `gomod` entry at `/` runs `weekly`, groups `golang.org/x/*` into one pull request and the two `swaggo` modules into another with `patterns`, and leaves the framework and ORM to their own pull requests so a reviewer sees an Echo bump alone. The `github-actions` entry bumps `checkout` and `setup-go`, and the `docker` entry watches the two `FROM` lines. Two modules get a sentence in the pull request instead of a rule: `dgrijalva/jwt-go`, whose repository is archived and whose maintained successor `github.com/golang-jwt/jwt` is a different module path, and `jinzhu/gorm`, whose v2 lives at `gorm.io/gorm`. Dependabot updates versions, not import paths, so neither will ever get a pull request from it, and the agent lists them as the upgrades a person has to start by hand.

Before it opens anything the agent proves the configuration is sound and the suite is green. It runs `go mod tidy` and checks `go.mod` and `go.sum` are unchanged, runs `go build ./...` and `go test -race ./...` from its sandbox, where `handler/handler_test.go` migrates and drops `./../realworld_test.db` through `db.TestDB`, and validates the YAML against the keys GitHub documents (`package-ecosystem`, `directory`, `schedule.interval`, `groups`, `open-pull-requests-limit`). The command output is kept with the run, so the reviewer can see that the tests passed on the same module set Dependabot will now be bumping.

## Start it with one API call

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

```json
{
  "agent": "claude",
  "input": "Add Dependabot to this Echo API. Read go.mod, go.sum, the workflow under .github/workflows, the Makefile and the Dockerfile first. Write .github/dependabot.yml with weekly gomod, github-actions and docker entries at /, group golang.org/x/* and the swaggo modules, keep echo and gorm as separate pull requests, and set open-pull-requests-limit to 10 for gomod. Do not change go.mod. Run go mod tidy, go build ./... and go test -race ./... and quote the output in the pull request. In the description, name the modules Dependabot cannot upgrade because their successor lives at another import path, and the Docker base images and what versions they would track. Open a pull request.",
  "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

The pull request adds one file, `.github/dependabot.yml`, and a short section in `readme.md` on how the groups are meant to be reviewed. Its description quotes the `go build` and `go test -race` output, lists the three ecosystems and the two groups, and names the modules that need a hand-made migration (`jwt-go` to `golang-jwt/jwt`, `jinzhu/gorm` to `gorm.io/gorm`) and the two `FROM` images with what each would be bumped toward.

A reviewer checks three things before merging: that the `directory` is `/` and not a subfolder, that the group patterns match the module paths in `go.mod` and nothing else, and that the weekly schedule and the pull request limit fit how often they want to review. Once merged, Dependabot's first pass opens pull requests against the `go 1.18` toolchain the workflow installs, so the reviewer also decides whether `setup-go` should move to a newer version first.

Nothing in the application changes. Every handler, store and test file is as it was, and the branch differs from `main` by the configuration file and the readme section.

## Run it on every new Go repository

A team that adds Go services often starts this from its own server: a handler that lists the repositories it owns, and for each one with a `go.mod` and no `.github/dependabot.yml`, sends this body to `POST /o/{org}/sessions` with that repository in `resources`. A `request_id` that is a UUID v5 of the repository's full name makes the call safe to retry, because the same `request_id` and body return the run already started.

Dependabot's own pull requests do not fire a Rush `github` trigger, since bot senders never do. To get a weekly look at what it opened, add an automation with a `schedule` trigger (`cron` for Monday morning in the team's time zone) whose prompt reads the open Dependabot pull requests and comments on each with what changed in `go.sum` and whether `go test -race ./...` passes on the branch. An automation's runs are read-only, so they comment and never push.

## Why run it on Rush?

The hard part of this job is not the YAML but knowing what it will produce, and that means reading `go.mod`, running the build and the tests, and naming the modules Dependabot cannot touch. The agent does that in its own sandbox with Go installed, runs `go test -race ./...` against the SQLite test database the suite creates, and keeps every command and its output with the pull request, so the reviewer reads evidence rather than a promise.

A team with several Go services on Echo, Gin or chi starts the same request for each repository at once. Each run reads its own `go.mod` and workflow, so one service gets a `docker` entry because it has a `Dockerfile` and another does not, and each pull request says what Dependabot will and will not be able to update in that repository.

## Frequently asked questions

### Will Dependabot upgrade jwt-go or gorm to their maintained versions?

No. `github.com/dgrijalva/jwt-go` is archived and its successor is `github.com/golang-jwt/jwt`; `github.com/jinzhu/gorm` v2 is published as `gorm.io/gorm`. Both are new import paths, and Dependabot bumps versions within a module path only. The pull request lists them as migrations a person or a separate run starts.

### Why group golang.org/x packages?

They release together and the `x/crypto`, `x/net`, `x/sys`, `x/text` and `x/tools` lines in `go.sum` usually move at once. One grouped pull request runs the suite once instead of five times, and a `groups` entry with `patterns: ["golang.org/x/*"]` is all it takes.

### What does the docker entry do with an untagged alpine image?

Nothing, because there is no version to bump. The pull request says so and suggests pinning `alpine` to a tag so later bumps are visible. The `golang:1.12.1` build image is older than the `go 1.18` directive in `go.mod`, which the agent points out rather than changing the Dockerfile in a configuration pull request.

### Does the agent change go.mod?

No. It runs `go mod tidy` to confirm `go.mod` and `go.sum` are already tidy, and reverts any difference. Upgrading modules is Dependabot's job once the configuration is merged, and a pull request that mixes the two is harder to review.

### Will the Go 1.18 toolchain in the workflow block updates?

It can. A dependency that requires a newer `go` directive fails `go build` on `actions/setup-go` with `go-version: 1.18`, and Dependabot's pull request shows a red check. The pull request description names this and suggests moving `setup-go` to a current Go first, which a reviewer can do in one line.

## More Echo jobs

- [Add golangci-lint to an Echo API's CI](https://getrush.ai/run/add-golangci-lint-to-ci/echo/)
- [Add Graceful Shutdown to an Echo App](https://getrush.ai/run/add-graceful-shutdown/echo/)
- [Add Health Checks to an Echo API](https://getrush.ai/run/add-health-checks/echo/)

## The same job on other stacks

- [Add Dependabot to an Elixir Library](https://getrush.ai/run/add-dependabot/elixir/)
- [Set Up Dependabot for a Flutter App's Pub, Gradle and Actions Dependencies](https://getrush.ai/run/add-dependabot/flutter/)
- [Add Dependabot to a Go CLI Repository](https://getrush.ai/run/add-dependabot/go-cli/)

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