Agent publishing
The ChatGPT GitHub connector can create branches and post issue comments, but it cannot dispatch a
workflow. Connector branches would otherwise merge as prillcode history. This handoff turns an
allowlisted staged branch into a pull request authored by commitmentdesk-dev[bot], with one
bot-authored commit that becomes the squashed commit on main.
Guarantees
Section titled “Guarantees”- The pull request branch, pull request author, and commit author and committer are the bot.
- The pull request contains one commit. The staged branch’s intermediate commits are not replayed.
- The staged branch is fetched by exact SHA but is never checked out, and no code from it runs in the privileged workflow.
- The workflow runs only trusted scripts from
main. It does not runpnpm, tests, hooks, or project code from the staged branch. - The staged connector branch is deleted after the bot pull request is created, unless the command
sets
delete_sourcetofalse. - A human merges the bot pull request with Squash and merge. The connector branch is never merged.
One-time setup
Section titled “One-time setup”1. GitHub App permissions
Section titled “1. GitHub App permissions”The app is commitmentdesk-dev (app ID 5931569, slug commitmentdesk-dev). Grant only:
| Permission | Level |
|---|---|
| Contents | Write |
| Pull requests | Write |
| Metadata | Read |
Remove any broader permissions such as Actions, Discussions, Issues, Packages, or Workflows. The prillcode owner currently has to change this in the app settings; the API does not let the app edit its own permissions. The workflow also downscopes its installation token to Contents and Pull requests, so a broader installation is not used by the publish path.
The app must not be allowed to bypass branch protection or push to main. It only pushes bot/*
branches and opens pull requests.
2. Repository variable and secret
Section titled “2. Repository variable and secret”gh variable set BOT_APP_ID --body 5931569gh secret set BOT_APP_PRIVATE_KEY < ~/.config/commitment-desk/commitmentdesk-dev.pemThe private key stays in GitHub Actions secrets. Never commit it or paste it into a chat.
Optional: set BOT_PUBLISH_MAX_PATCH_BYTES as a repository variable to change the 10 MiB patch
limit.
3. Publish issue
Section titled “3. Publish issue”Create the label and one long-lived issue:
gh label create agent-publish \ --description "Accepts /publish-bot commands from the allowlisted actor" \ --color 5319e7
gh issue create \ --title "Agent publish commands" \ --label agent-publish \ --body "Post /publish-bot commands here. See docs/operations/agent-publishing.md."Keep the issue open. The workflow only accepts comments on an open issue with the agent-publish
label, from the actor hardcoded in .github/workflows/publish-bot.yml (prillcode). To change the
actor, edit the workflow in a human-authored pull request.
4. Merge settings
Section titled “4. Merge settings”Use squash-only merges and delete head branches after merge:
gh api --method PATCH repos/commitmentdesk/commitment-desk \ -F allow_squash_merge=true \ -F allow_merge_commit=false \ -F allow_rebase_merge=false \ -F delete_branch_on_merge=true \ -f squash_merge_commit_title=PR_TITLE \ -f squash_merge_commit_message=PR_BODYGitHub uses the pull request author as the squash commit author. Because the bot opens the pull
request, the commit on main is bot-authored even when a human clicks Squash and merge.
5. Branch protection
Section titled “5. Branch protection”Enable protection for main when the repository plan supports it:
- Require a pull request before merging.
- Require at least one approval from a human.
- Require the CI checks:
Verify,Security,Browser acceptance, andSelf-host contract. - Dismiss stale approvals and require conversation resolution.
- Block force pushes and deletions.
- Do not add the app to the bypass list.
Private repositories on the GitHub Free plan cannot enable branch protection or rulesets. Until the
repository is public or the plan is upgraded, the owner must merge carefully and only merge the
bot/* pull request, never the staged connector branch. The workflow itself never merges.
Command format
Section titled “Command format”Post a comment on the open agent-publish issue:
/publish-bot```json{ "branch": "chatgpt/branding-2026-11-26", "sha": "0123456789abcdef0123456789abcdef01234567", "title": "feat(web): add branded app shell", "body": "Optional pull request description.", "delete_source": true}```Fields:
| Field | Required | Rules |
|---|---|---|
branch |
Yes | chatgpt/... or agent/...; must be the current branch tip |
sha |
Yes | Full 40-character lowercase commit SHA |
title |
Yes | Conventional commit, single line, at most 200 characters |
body |
No | Pull request description and commit body, at most 20000 characters |
delete_source |
No | Delete the staged branch after publishing; defaults to true |
The command must start with /publish-bot. A bare JSON object after the command also works. Unknown
fields, unsafe branch names, a SHA that does not match the branch tip, and non-conventional titles
are rejected.
The parser removes Co-authored-by, Signed-off-by, and Author trailers from the supplied body.
The workflow appends one Signed-off-by trailer for the bot so the commit satisfies the DCO without
attributing the change to prillcode.
What the workflow does
Section titled “What the workflow does”- Checks out the current
mainwith no persisted credentials and disables Git hooks. - Parses the command from the comment; no comment text is interpolated into a shell command.
- Mints a short-lived installation token for the app, downscoped to Contents and Pull requests.
- Fetches the staged branch by name and verifies its tip equals the requested SHA.
- Computes the diff from the merge base with
mainand checks that it applies to currentmain. - Rejects protected paths, oversized patches, and patches touching more than 500 files.
- Creates a
bot/<slug>-<sha>branch from currentmain, applies the diff withgit apply, and commits once with the bot as author and committer. - Pushes the bot branch with the app token and creates or updates the pull request with the app token.
- Deletes the staged branch and comments the result on the publish issue.
If the staged branch is based on older main and the diff no longer applies, rebase or recreate the
staged branch and post a new command with its current tip. The workflow does not merge or rebase the
staged branch.
Safety boundaries
Section titled “Safety boundaries”- Only
prillcodecan trigger the workflow, only on an open issue labeledagent-publish, only forchatgpt/oragent/branches. - The staged branch is never checked out and its code never runs in the privileged workflow.
- The app private key is available only to the token-minting step; the token is masked, short-lived, revoked at job end, and downscoped.
- Automated publishes reject every
.github/**path and.gitmodules. This keeps the workflow, action, and privileged parser changes out of the bot path. Open a human-authored pull request for those changes. - The privilege boundary is the diff, not the connector branch. The bot branch is still ordinary repository code and runs normal pull request CI.
- Keep pull request CI free of deployment credentials. Use protected environments for deployment.
- Do not merge the staged connector branch. Merge only the
bot/*pull request.
Dry run
Section titled “Dry run”Use a small docs-only change for the first publish:
-
Create
agent/publish-smoke-<date>frommainand commit a docs change as the connector would. -
Push the branch and note its full commit SHA.
-
Post the
/publish-botcommand on the publish issue. -
Confirm the workflow created a
bot/*branch and a pull request. -
Confirm the pull request author is
commitmentdesk-dev[bot]and the pull request has one commit. -
Confirm the commit author and committer:
Terminal window git log -1 --format='Author: %an <%ae>%nCommitter: %cn <%ce>' -
Merge with Squash and merge, then confirm the commit on
main:Terminal window git log -1 --format='Author: %an <%ae>%nCommitter: %cn <%ce>' -
Confirm the staged
agent/branch is gone and thebot/*head branch was deleted after merge.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Action |
|---|---|
| Workflow did not start | Check the issue is open, has the agent-publish label, and the comment starts with /publish-bot from prillcode. |
The staged branch ... is at ... |
Post a new command with the branch’s current tip SHA. |
The patch is ... bytes |
Split the change or raise BOT_PUBLISH_MAX_PATCH_BYTES. |
cannot change protected paths |
Open a human-authored pull request for workflow or repository config. |
patch does not apply |
Rebase or recreate the staged branch on current main, then republish. |
title must be a conventional commit |
Use a title such as fix(api): reject expired magic links. |
Resource not accessible by integration |
Check the app installation has Contents and Pull requests write access. |
| Pull request checks do not run | Confirm the bot branch is in this repository and CI is enabled. |
Verification record
Section titled “Verification record”The first publish used the docs-only agent/publish-smoke-20261126 branch. The resulting pull
request and squashed commit were verified to be authored by commitmentdesk-dev[bot], and the staged
branch was deleted after publishing.
Limitations
Section titled “Limitations”- The connector identity still authors the temporary staged-branch commits. They are not merged and are deleted after publishing, but their objects may remain reachable by SHA for a while.
- The bot cannot approve its own pull request. A human must review and merge.
- Branch protection is unavailable on a private repository on the GitHub Free plan.
- A merged pull request cannot be republished from the same bot branch. Push a new staged commit.