Skip to content

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.

  • 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 run pnpm, 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_source to false.
  • A human merges the bot pull request with Squash and merge. The connector branch is never merged.

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.

Terminal window
gh variable set BOT_APP_ID --body 5931569
gh secret set BOT_APP_PRIVATE_KEY < ~/.config/commitment-desk/commitmentdesk-dev.pem

The 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.

Create the label and one long-lived issue:

Terminal window
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.

Use squash-only merges and delete head branches after merge:

Terminal window
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_BODY

GitHub 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.

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, and Self-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.

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.

  1. Checks out the current main with no persisted credentials and disables Git hooks.
  2. Parses the command from the comment; no comment text is interpolated into a shell command.
  3. Mints a short-lived installation token for the app, downscoped to Contents and Pull requests.
  4. Fetches the staged branch by name and verifies its tip equals the requested SHA.
  5. Computes the diff from the merge base with main and checks that it applies to current main.
  6. Rejects protected paths, oversized patches, and patches touching more than 500 files.
  7. Creates a bot/<slug>-<sha> branch from current main, applies the diff with git apply, and commits once with the bot as author and committer.
  8. Pushes the bot branch with the app token and creates or updates the pull request with the app token.
  9. 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.

  • Only prillcode can trigger the workflow, only on an open issue labeled agent-publish, only for chatgpt/ or agent/ 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.

Use a small docs-only change for the first publish:

  1. Create agent/publish-smoke-<date> from main and commit a docs change as the connector would.

  2. Push the branch and note its full commit SHA.

  3. Post the /publish-bot command on the publish issue.

  4. Confirm the workflow created a bot/* branch and a pull request.

  5. Confirm the pull request author is commitmentdesk-dev[bot] and the pull request has one commit.

  6. Confirm the commit author and committer:

    Terminal window
    git log -1 --format='Author: %an <%ae>%nCommitter: %cn <%ce>'
  7. Merge with Squash and merge, then confirm the commit on main:

    Terminal window
    git log -1 --format='Author: %an <%ae>%nCommitter: %cn <%ce>'
  8. Confirm the staged agent/ branch is gone and the bot/* head branch was deleted after merge.

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.

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.

  • 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.