Bots
Team-owned bots, limited to groups and repositories, and their keys limited further by scope and binding.
A bot is an account that belongs to a team, not a person, for automation that should keep working when people come and go. Every bot has a role (read, write or maintain), which caps everything its keys can do. A bot is never an administrator.
Limiting a bot to groups and repositories
By default a bot reaches every repository of its team. You can limit it to some groups and repositories (up to 50). A group covers everything under it. This is a ceiling for all of the bot's keys:
- a key's bindings must sit inside the bot's resources when it is issued;
- on every request, branchd intersects the key's bindings with the bot's current resources, so narrowing a bot cuts its existing keys at once.
# Create a bot that may reach only one group
branchd bot create acme/deployer --role write --group acme/services
# Narrow it to one repository, or widen it back to the whole team
branchd bot update acme/deployer --repo acme/services/api
branchd bot update acme/deployer --whole-teamIn the console, this is under the group's Bots settings.
Bot keys
A bot key carries scopes and, optionally, bindings:
# The git preset: clone (and push, if the bot's role is above read)
branchd bot token acme/deployer --kind git
# Exactly the scopes a job needs, on one repository
branchd bot token acme/deployer --scopes forge:package:read --repo acme/services/api
# A level, never above the bot's role
branchd bot token acme/deployer --level write --group acme/services| Flag | Meaning |
|---|---|
--kind git | forge:contents:read, plus forge:contents:edit when the bot's role is write or maintain |
--kind api | The API preset: the read level, or the write level for a write or maintain bot |
--level LEVEL | read, write or maintain, never above the bot's role |
--scopes S,... | Exactly these scopes |
--repo PATH, --group PATH | Bind the key to these, inside the bot's own resources. Repeatable. |
--name NAME | A label for the key (default: its kind and the time) |
--expires DURATION | How long until it stops working, as a duration such as 2160h (90 days) |
Use one of --kind, --level or --scopes. Without --repo or
--group, a limited bot's key is bound to all of the bot's resources, and
a whole-team bot's key reaches the whole team.
In the API, CreateBot and UpdateBot take resources[]
({kind: GROUP or REPOSITORY, path}; empty means the whole team, and
update_mask resources changes it). CreateBotCredential takes
kind, or level and/or scopes, and bindings[] with optional
per-binding scopes, each inside the key's own scopes.