By default autodev uses a personal token, so everything it does on GitHub shows up as you. With a GitHub App it
acts as its own bot account, <app-slug>[bot]:
| what | personal token | GitHub App |
|---|---|---|
| issue/PR comments, labels | you | <app-slug>[bot] |
opening the PR, pushing autodev/issue-N |
you | <app-slug>[bot] |
| agent commits (author) | you | <app-slug>[bot], with the bot's avatar |
| approving autodev's PRs | /approve <sha> comment (you can't approve your own PR) |
a normal Approve review |
You need to be an owner of the JaneliaSciComp org, or an org owner has to make you a GitHub App manager, to create
the App and install it. Everything else is done as the account that runs autodev. Back to the
README. The service-account checklist is in notes/autodev-runbook.md.
Go to github.com/organizations/JaneliaSciComp/settings/apps and click New GitHub App.
-
GitHub App name: this sets the bot's login, e.g.
mia-autodevbecomesmia-autodev[bot]. It must be unique across GitHub. -
Homepage URL:
https://github.com/JaneliaSciComp/mia-workflow-prototype. -
Callback URL, Setup URL, "Request user authorization": leave empty or unchecked. autodev never acts on behalf of a user.
-
Webhook: uncheck Active. autodev polls, and the worker accepts no inbound connections.
-
Repository permissions:
permission access Contents Read and write Pull requests Read and write Issues Read and write Checks Read-only Commit statuses Read-only Metadata Read-only (required) Leave everything else, including Workflows and Administration, at No access. Without Workflows the bot can't change
.github/workflows/, and autodev refuses agent changes under.github/anyway. -
Organization and account permissions: none.
-
Subscribe to events: none.
-
Where can this GitHub App be installed?: Only on this account.
Click Create GitHub App.
On the App's General page:
- Copy the App ID. This is a number. Don't use the Client ID, which starts with
Iv. - Under Private keys, click Generate a private key. A
.pemfile downloads.
Move the key to the account that runs autodev, and make it readable only by that account:
mkdir -p ~/.config/autodev
mv ~/Downloads/<app-name>.*.private-key.pem ~/.config/autodev/app.pem
chmod 600 ~/.config/autodev/app.pemKeep the key out of the repo and out of paths.work_root. The config refuses agent.extra_mounts that overlap it,
and agent jobs never see it.
On the App's page, click Install App, choose JaneliaSciComp, then Only select repositories, and pick
mia-workflow-prototype (or whichever repos autodev should watch). Click Install.
You land on a page like github.com/organizations/JaneliaSciComp/settings/installations/12345678. The number at
the end is the installation ID.
In autodev.yaml:
github:
repo: JaneliaSciComp/mia-workflow-prototype
auth: app
app_id: 123456 # step 2
installation_id: 12345678 # step 3
private_key_path: ~/.config/autodev/app.pem # step 2token_env and token_file are ignored when auth: app. mia up binds the key read-only into
the worker's sandbox. The worker signs a short-lived JWT with the key and exchanges it for an installation token,
which it renews about once an hour.
pixi run mia exec autodev checkThe github identity row should show <app-slug>[bot] and the github repo row should be ok. If the labels
don't exist yet for this repo, run pixi run mia exec autodev init-labels.
Changing the identity changes who autodev believes it is. It recognizes its own round summaries and "handled feedback" markers by login, so on a PR that's already open under the old identity it would redo feedback it already handled, and repost its comments. Switch when nothing is in flight:
- Finish or close every issue labelled
<deployment>:workingor<deployment>:review, e.g.gh issue list -R JaneliaSciComp/mia-workflow-prototype -l autodev:review. pixi run mia restart autodev(or the service name the App runs under).
At startup the worker looks up the bot user's ID and sets the commit author on every agent workspace to
<app-slug>[bot] <ID+<app-slug>[bot]@users.noreply.github.com>, which is how GitHub links commits to the bot.
Now that the bot is a separate account, protect main. Under Settings → Rules → Rulesets (or
Branches) on the repo:
- Require a pull request before merging, with 1 approving review.
- Dismiss stale approvals when new commits are pushed.
- Don't add the App to the bypass list.
autodev only merges after an approval from someone with write access, and GitHub enforces the same rule. Reviewers
now click Approve. /approve <sha> comments still work, but they don't satisfy branch protection.
Add .github/CODEOWNERS covering autodev/, mia_ops/ and .github/ so changes to the gates need a named human
(see the runbook).
- Rotate the key: generate a new one on the App's page, replace
app.pem,pixi run mia restart autodev, then delete the old key on GitHub. - Adding permissions later: after you change the App's permissions, an org owner has to accept the new permissions on the installation page before they take effect.
401 ... JSON web token could not be decodedorIntegration not found: theapp_idis wrong, or the key belongs to another App.404on/app/installations/.../access_tokens: theinstallation_idis wrong, or the App was uninstalled.403 Resource not accessible by integration: a permission from step 1 is missing, or the repo isn't in the installation's repository list.- Commits show a plain name with no avatar: the worker started before the switch. Restart it.