Expand description
The gh commands a container agent cannot run with its own token, and what it does instead.
A container’s GitHub token reads contents and writes pull requests, issues and the rest; it cannot write contents.
Two kinds of gh command need that:
gh pr mergemerges a pull request. srv does it for the container (POST /api/v1/github/pr-merge) with the host’sgh-agent, from a repository, a number and three options. Anything else a merge takes is refused here, with what to do.- A raw
gh apiwrite that changes a ref, a tag, a release or a file (DELETE .../git/refs/heads/x,PUT .../contents/f,POST .../releases) would only fail at GitHub with “Resource not accessible by integration”. It is refused here instead, naming the command that does the job:git push,gh pr merge --delete-branch.
github-container -- <gh args> is what the gh function calls for a container’s command. It exits 0 when it did the
job, 1 when it refused or failed (the reason on stderr), and 3 when the command is not one of these and gh should
run as usual.
Structs§
- Merge
- A merge as the container asked for it.
Enums§
- Parsed
- What
gh pr merge <args>means: a merge srv can do,Helpfor--help, or why it cannot be done here.
Constants§
- BY_
NUMBER 🔒 - MERGE_
TIMEOUT 🔒 - srv runs the merge on the host and may wait on GitHub and a merge queue.
- NOT_
HANDLED - Exit status meaning “not for this command: run
ghas usual”. - RELEASE 🔒
Functions§
- ask_
merge 🔒 - lead_
repo_ flag - A repository flag in front of the command word (
gh -R o/r pr merge 7, whichghaccepts): the repository it names, and the arguments without it.Nonefor a command that does not start with one, or whose flag is notOWNER/REPO(thenghitself says what is wrong). - merge_
body - The request srv gets: the repository, the number and the three options, nothing else.
- merge_
repo 🔒 - The repository a merge is on: the one the merge names, else a leading
-R, elseGH_REPO, else the working directory’s. AGH_REPOthat is not a plain repository is refused, not replaced by the working directory’s. - narrowing_
machine - Whether this container’s machine narrows its GitHub tokens: it has a gh-agent (
AGENTMUX_PUBLISH_GUARDis1, orolder-gh-agentwhere it is installed but too old to narrow, which srv then says out loud). With0, no value or any other value there is no gh-agent on the machine, the container’s token comes from the person’s own GitHub connection, and itsghcommands run as they always did. - parse_
merge gh pr merge’s arguments (argsstart withpr merge).- refused_
api 🔒 - refused_
command - The refusal for a raw
gh apiwrite a container’s token cannot make, with the command that does the job;Nonefor every otherghcommand.argsaregh’s own, starting withapi. - repo_
of_ 🔒flag - The repository a
-R/--repo/GH_REPOvalue names. The whole spec must beOWNER/REPOorgithub.com/OWNER/REPO: another host, or a longer path, names a repository this step cannot merge on, and is never cut down to its first two parts (that would merge on a different repository than the one named). - run_
github_ container github-container -- <gh args>.- unsupported 🔒