Skip to content

Commit dd7bcc3

Browse files
committed
feat(github-action): add remote server connection support via --attach
Add support for connecting the GitHub Action to a remote OpenCode server, enabling execution on persistent servers with deep context and warm caches. Changes: - Add server_url input for remote server URL (e.g., https://agent.acme.com:4096) - Add server_password input for authentication (via GitHub secrets) - Modify createOpencode() to conditionally connect to remote server - Add validation ensuring password is paired with URL - Handle cleanup: skip kill() for remote servers Closes anomalyco#15801
1 parent b751bd0 commit dd7bcc3

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎github/action.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ inputs:
3838
description: "Base URL for OIDC token exchange API. Only required when running a custom GitHub App install. Defaults to https://api.opencode.ai"
3939
required: false
4040

41+
server_url:
42+
description: "URL of a remote OpenCode server to connect to (e.g., https://agent.acme.com:4096). Enables remote execution on persistent servers."
43+
required: false
44+
45+
server_password:
46+
description: "Password for the remote OpenCode server (should be passed via GitHub secrets). Required if server_url is provided and server is password protected."
47+
required: false
48+
4149
runs:
4250
using: "composite"
4351
steps:
@@ -77,3 +85,5 @@ runs:
7785
MENTIONS: ${{ inputs.mentions }}
7886
VARIANT: ${{ inputs.variant }}
7987
OIDC_BASE_URL: ${{ inputs.oidc_base_url }}
88+
SERVER_URL: ${{ inputs.server_url }}
89+
SERVER_PASSWORD: ${{ inputs.server_password }}

‎github/index.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,33 @@ try {
228228
process.exit(exitCode)
229229

230230
function createOpencode() {
231+
const serverUrl = useEnvServerUrl()
232+
const serverPassword = useEnvServerPassword()
233+
234+
if (serverPassword && !serverUrl) {
235+
throw new Error("server_password provided without server_url. Remote authentication requires a target host.")
236+
}
237+
238+
if (serverUrl) {
239+
const headers: Record<string, string> = {}
240+
if (serverPassword) {
241+
headers["Authorization"] = `Bearer ${serverPassword}`
242+
}
243+
244+
const client = createOpencodeClient({
245+
baseUrl: serverUrl,
246+
headers: Object.keys(headers).length > 0 ? headers : undefined,
247+
})
248+
249+
return {
250+
server: {
251+
url: serverUrl,
252+
close: () => {},
253+
},
254+
client,
255+
}
256+
}
257+
231258
const host = "127.0.0.1"
232259
const port = 4096
233260
const url = `http://${host}:${port}`
@@ -337,6 +364,14 @@ function useEnvMock() {
337364
}
338365
}
339366

367+
function useEnvServerUrl() {
368+
return process.env["SERVER_URL"] || undefined
369+
}
370+
371+
function useEnvServerPassword() {
372+
return process.env["SERVER_PASSWORD"] || undefined
373+
}
374+
340375
function useEnvGithubToken() {
341376
return process.env["TOKEN"]
342377
}

0 commit comments

Comments
 (0)