Skip to content

feat(api): real /api/publish endpoint with GitHub workflow_dispatch#44

Merged
Delqhi merged 1 commit into
mainfrom
feat/api-publish-real
Jun 12, 2026
Merged

feat(api): real /api/publish endpoint with GitHub workflow_dispatch#44
Delqhi merged 1 commit into
mainfrom
feat/api-publish-real

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the simulated Publish button (setTimeout → deployed) with a real network request to POST /api/publish that triggers the GitHub Actions docker.yml workflow via workflow_dispatch.

Changes

  • app/api/publish/route.ts — New POST-only endpoint. Validates GITHUB_REPO + GITHUB_TOKEN env vars, calls GitHub REST API to dispatch docker.yml, handles 401/429 with Retry-After, returns 202 on success. All non-POST methods return 405.
  • components/publish-menu.tsx — Replaced window.setTimeout with fetch("/api/publish"). Added error state with real error message display. Button now shows "Retry" on error.
  • .env.example — Added GITHUB_REPO and GITHUB_TOKEN placeholders with documentation.

Deployment strategy

Option C from #39: GitHub workflow_dispatch trigger.

  • Least infra coupling — no Docker socket mount, no extra services
  • Uses existing GITHUB_TOKEN (needs workflow scope)
  • The VPS pulls the new image and restarts after the workflow completes
  • The docker.yml workflow already supports workflow_dispatch on line 13

Request / Response shape

Request:

POST /api/publish
{
  "chatId": "abc123",
  "visibility": "private"
}

Success (202):

{
  "status": "dispatched",
  "message": "Deploy workflow triggered for OpenSIN-Code/SIN-Code-WebUI-v2. Check GitHub Actions for progress.",
  "repo": "OpenSIN-Code/SIN-Code-WebUI-v2",
  "chatId": "abc123",
  "visibility": "private"
}

Error (503 — not configured):

{
  "status": "error",
  "message": "Publish is not configured. Set GITHUB_REPO and GITHUB_TOKEN in .env."
}

User configuration

Set in .env (or .env.development.local.md):

GITHUB_REPO=OpenSIN-Code/SIN-Code-WebUI-v2
GITHUB_TOKEN=ghp_...  (needs "workflow" scope)

Verification

  • pnpm tsc --noEmit → exit 0
  • pnpm build → success
  • /api/publish appears as dynamic route in build output
  • Secret scan on diff → 0 hits

Closes #39

- Add POST /api/publish route that triggers docker.yml via GitHub REST API
- Handle 401, 429 with Retry-After, return 202 on success
- Replace simulated setTimeout in PublishMenu with real fetch call
- Add error state UI to PublishMenu (shows API errors)
- Add GITHUB_REPO + GITHUB_TOKEN placeholders to .env.example
- Closes #39

Co-authored-by: subagent-39 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

CEO Audit — Not applicable

This repository is a Node.js / TypeScript project.
The CEO Audit is a Python tool; running it on a non-Python
repo would produce a misleading grade.

Recommended checks for this repo:

  • pnpm tsc --noEmit (type safety)
  • pnpm lint (style)
  • pnpm test (unit tests, when added)

@Delqhi Delqhi merged commit 0510b7a into main Jun 12, 2026
1 of 2 checks passed
@Delqhi Delqhi deleted the feat/api-publish-real branch June 12, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] Publish button — real /api/publish endpoint that triggers a deploy

1 participant