feat(api): real /api/publish endpoint with GitHub workflow_dispatch#44
Merged
Conversation
- 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>
CEO Audit — Not applicableThis repository is a Node.js / TypeScript project. Recommended checks for this repo:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the simulated Publish button (
setTimeout → deployed) with a real network request toPOST /api/publishthat triggers the GitHub Actionsdocker.ymlworkflow viaworkflow_dispatch.Changes
app/api/publish/route.ts— New POST-only endpoint. ValidatesGITHUB_REPO+GITHUB_TOKENenv vars, calls GitHub REST API to dispatchdocker.yml, handles 401/429 with Retry-After, returns 202 on success. All non-POST methods return 405.components/publish-menu.tsx— Replacedwindow.setTimeoutwithfetch("/api/publish"). Addederrorstate with real error message display. Button now shows "Retry" on error..env.example— AddedGITHUB_REPOandGITHUB_TOKENplaceholders with documentation.Deployment strategy
Option C from #39: GitHub
workflow_dispatchtrigger.GITHUB_TOKEN(needsworkflowscope)docker.ymlworkflow already supportsworkflow_dispatchon line 13Request / Response shape
Request:
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):Verification
pnpm tsc --noEmit→ exit 0pnpm build→ success/api/publishappears as dynamic route in build outputCloses #39