Sync: rewrite upstream-ci and pull-request against the Forgejo API #1

Open
opened 2026-11-22 04:26:03 +00:00 by terra · 0 comments
Member

Purpose (capability): the nightly upstream sync runs on the forge again: it merges upstream main, runs the fork's checks and upstream's core CI on the sync branch, and opens a pull request on the forge for a human to read.

Refs macula-io/martha#601.

Why

The Supervisor's ruling on the martha-engine forge port (2026-11-22, Q3 (a)): park martha-engine-sync.yml on the forge now (every job guarded by if: github.server_url == 'https://github.com'), and file the Forgejo API rewrite as its own package.

The merge and checks jobs would work on the forge as they are. Two jobs call the GitHub API through gh and cannot:

  • upstream-ci (lines 78-100): gh workflow run ci.yml --ref "$BRANCH", gh run list ... --json databaseId, gh run watch --exit-status.
  • pull-request (lines 124-144): gh api repos/${GH_REPO}/commits/${SYNC}, gh pr create.

What the rewrite has to answer

  • Dispatching ci.yml on the sync branch: Forgejo 15 has a workflow dispatch endpoint; check that it is there and that the run token may call it.
  • Waiting on that run: the forge has no jobs API. /actions/runs gives status and conclusion by commit_sha, so the wait reads runs by the sync tip, without polling hard.
  • Opening the PR: POST /api/v1/repos/{owner}/{repo}/pulls with head, base, title and body; first check whether one is already open for that head.
  • The token: the run token, or a scoped deploy token, and the permissions it needs.

Done when

  • The sync's upstream-ci and pull-request jobs call the Forgejo API, not gh, and the server_url guard is lifted from the sync on the forge only.
  • One manual dispatch of the sync on the forge merges, runs ci.yml's four core jobs on the sync branch, and opens (or finds) the PR. The run ids are named on this issue.
  • The sync on github.com is unchanged: it still runs there under its own guard.
Purpose (capability): the nightly upstream sync runs on the forge again: it merges upstream main, runs the fork's checks and upstream's core CI on the sync branch, and opens a pull request on the forge for a human to read. Refs macula-io/martha#601. ## Why The Supervisor's ruling on the martha-engine forge port (2026-11-22, Q3 (a)): park `martha-engine-sync.yml` on the forge now (every job guarded by `if: github.server_url == 'https://github.com'`), and file the Forgejo API rewrite as its own package. The `merge` and `checks` jobs would work on the forge as they are. Two jobs call the GitHub API through `gh` and cannot: - `upstream-ci` (lines 78-100): `gh workflow run ci.yml --ref "$BRANCH"`, `gh run list ... --json databaseId`, `gh run watch --exit-status`. - `pull-request` (lines 124-144): `gh api repos/${GH_REPO}/commits/${SYNC}`, `gh pr create`. ## What the rewrite has to answer - Dispatching ci.yml on the sync branch: Forgejo 15 has a workflow dispatch endpoint; check that it is there and that the run token may call it. - Waiting on that run: the forge has no jobs API. `/actions/runs` gives status and conclusion by commit_sha, so the wait reads runs by the sync tip, without polling hard. - Opening the PR: `POST /api/v1/repos/{owner}/{repo}/pulls` with head, base, title and body; first check whether one is already open for that head. - The token: the run token, or a scoped deploy token, and the permissions it needs. ## Done when - The sync's upstream-ci and pull-request jobs call the Forgejo API, not `gh`, and the server_url guard is lifted from the sync on the forge only. - One manual dispatch of the sync on the forge merges, runs ci.yml's four core jobs on the sync branch, and opens (or finds) the PR. The run ids are named on this issue. - The sync on github.com is unchanged: it still runs there under its own guard.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
martha-ai/martha-engine#1
No description provided.