@@ -3,8 +3,12 @@ import {
33 normalizeRepositoryPath ,
44 type GitHubAutomationRegion ,
55} from "../adk/githubIntegration" ;
6+ import type { CloudProvider } from "../adk/cloudProvider" ;
67import {
78 baseBranchField ,
9+ cloudCredentialSecretLabels ,
10+ cloudCredentialSecretNames ,
11+ cloudProviderDisplayName ,
812 commonGitHubInput ,
913 initialAutomationValues ,
1014 repositoryField ,
@@ -20,9 +24,11 @@ interface RuntimeDeliveryWorkflowInput {
2024 runtimeName : string ;
2125 runtimeId : string ;
2226 region : GitHubAutomationRegion ;
27+ cloudProvider ?: CloudProvider ;
2328}
2429
2530const RUNTIME_ID_PATTERN = / ^ [ A - Z a - z 0 - 9 ] [ A - Z a - z 0 - 9 . _ : - ] { 0 , 127 } $ / ;
31+ const BYTEPLUS_VIKING_MEMORY_REGION = "cn-hongkong" ;
2632
2733export function validateRuntimeSettings (
2834 input : Pick < RuntimeDeliveryWorkflowInput , "runtimeName" | "runtimeId" > ,
@@ -38,6 +44,19 @@ export function validateRuntimeSettings(
3844
3945export function buildRuntimeDeliveryWorkflow ( input : RuntimeDeliveryWorkflowInput ) : string {
4046 validateRuntimeSettings ( input ) ;
47+ const cloudProvider = input . cloudProvider ?? "volcengine" ;
48+ const secrets = cloudCredentialSecretNames ( cloudProvider ) ;
49+ const byteplusEnv = cloudProvider === "byteplus"
50+ ? `
51+ VOLCENGINE_ACCESS_KEY: \${{ secrets.${ secrets . accessKey } }}
52+ VOLCENGINE_SECRET_KEY: \${{ secrets.${ secrets . secretKey } }}
53+ VOLCENGINE_SESSION_TOKEN: \${{ secrets.${ secrets . sessionToken } }}
54+ BYTEPLUS_REGION: ${ JSON . stringify ( input . region ) } `
55+ : "" ;
56+ const byteplusRuntimeEnv = cloudProvider === "byteplus"
57+ ? `
58+ "DATABASE_VIKING_REGION": ${ JSON . stringify ( BYTEPLUS_VIKING_MEMORY_REGION ) } ,`
59+ : "" ;
4160 const template = `name: Publish to AgentKit Runtime
4261
4362on:
@@ -55,15 +74,17 @@ concurrency:
5574
5675jobs:
5776 publish:
77+ if: \${{ github.event_name != 'push' || !contains(github.event.head_commit.message, '[skip runtime]') }}
5878 runs-on: ubuntu-latest
5979 defaults:
6080 run:
6181 working-directory: __PROJECT_PATH__
6282 env:
63- AGENTKIT_CLOUD_PROVIDER: volcengine
64- VOLC_ACCESSKEY: \${{ secrets.VOLCENGINE_ACCESS_KEY }}
65- VOLC_SECRETKEY: \${{ secrets.VOLCENGINE_SECRET_KEY }}
66- VOLC_SESSIONTOKEN: \${{ secrets.VOLCENGINE_SESSION_TOKEN }}
83+ AGENTKIT_CLOUD_PROVIDER: __CLOUD_PROVIDER__
84+ CLOUD_PROVIDER: __CLOUD_PROVIDER__
85+ __ACCESS_KEY_SECRET__: \${{ secrets.__ACCESS_KEY_SECRET__ }}
86+ __SECRET_KEY_SECRET__: \${{ secrets.__SECRET_KEY_SECRET__ }}
87+ __SESSION_TOKEN_SECRET__: \${{ secrets.__SESSION_TOKEN_SECRET__ }}__BYTEPLUS_ENV__
6788 AGENTKIT_RUNTIME_NAME: __RUNTIME_NAME__
6889 AGENTKIT_RUNTIME_ID: __RUNTIME_ID__
6990 AGENTKIT_REGION: __REGION__
@@ -90,10 +111,15 @@ jobs:
90111 from agentkit.toolkit import sdk
91112 from agentkit.toolkit.models import PreflightMode
92113
114+ credential_prefix = (
115+ "BYTEPLUS"
116+ if os.environ["AGENTKIT_CLOUD_PROVIDER"] == "byteplus"
117+ else "VOLCENGINE"
118+ )
93119 runtime_client = AgentkitRuntimeClient(
94- access_key=os.environ["VOLC_ACCESSKEY "],
95- secret_key=os.environ["VOLC_SECRETKEY "],
96- session_token=os.environ.get("VOLC_SESSIONTOKEN ", ""),
120+ access_key=os.environ[f"{credential_prefix}_ACCESS_KEY "],
121+ secret_key=os.environ[f"{credential_prefix}_SECRET_KEY "],
122+ session_token=os.environ.get(f"{credential_prefix}_SESSION_TOKEN ", ""),
97123 region=os.environ["AGENTKIT_REGION"],
98124 )
99125 runtime = runtime_client.get_runtime(
@@ -122,6 +148,10 @@ jobs:
122148 "runtime_name": runtime_name,
123149 "runtime_role_name": runtime_role_name,
124150 "python_version": "3.12",
151+ "runtime_envs": {
152+ "CLOUD_PROVIDER": os.environ["CLOUD_PROVIDER"],
153+ "AGENTKIT_CLOUD_PROVIDER": os.environ["AGENTKIT_CLOUD_PROVIDER"],__BYTEPLUS_RUNTIME_ENV__
154+ },
125155 }
126156 },
127157 }
@@ -141,6 +171,12 @@ jobs:
141171 __RUNTIME_NAME__ : JSON . stringify ( input . runtimeName ) ,
142172 __RUNTIME_ID__ : JSON . stringify ( input . runtimeId ) ,
143173 __REGION__ : JSON . stringify ( input . region ) ,
174+ __CLOUD_PROVIDER__ : JSON . stringify ( cloudProvider ) ,
175+ __ACCESS_KEY_SECRET__ : secrets . accessKey ,
176+ __SECRET_KEY_SECRET__ : secrets . secretKey ,
177+ __SESSION_TOKEN_SECRET__ : secrets . sessionToken ,
178+ __BYTEPLUS_ENV__ : byteplusEnv ,
179+ __BYTEPLUS_RUNTIME_ENV__ : byteplusRuntimeEnv ,
144180 __CONCURRENCY_GROUP__ : JSON . stringify ( `agentkit-runtime-${ input . runtimeId } ` ) ,
145181 } ;
146182 return Object . entries ( replacements ) . reduce (
@@ -173,15 +209,13 @@ export const runtimeDeliveryAutomation: GitHubAutomationDefinition = {
173209 runtimeNameField ,
174210 runtimeIdField ,
175211 ] ,
176- initialValues : initialAutomationValues ( ) ,
212+ initialValues : ( { cloudProvider } ) => initialAutomationValues ( cloudProvider ) ,
177213 regionHelp : "必须与目标 Runtime 所在地域一致" ,
178- secrets : [
179- "VOLCENGINE_ACCESS_KEY、VOLCENGINE_SECRET_KEY(必填)" ,
180- "VOLCENGINE_SESSION_TOKEN(使用临时凭据时必填)" ,
181- ] ,
182- submit ( values , signal ) {
214+ secrets : ( { cloudProvider } ) => cloudCredentialSecretLabels ( cloudProvider ) ,
215+ submit ( values , context , signal ) {
183216 const input = commonGitHubInput ( values ) ;
184217 const projectPath = normalizeRepositoryPath ( values . projectPath , "." ) ;
218+ const providerName = cloudProviderDisplayName ( context . cloudProvider ) ;
185219 return createGitHubPullRequest (
186220 {
187221 ...input ,
@@ -194,13 +228,14 @@ export const runtimeDeliveryAutomation: GitHubAutomationDefinition = {
194228 runtimeName : values . runtimeName . trim ( ) ,
195229 runtimeId : values . runtimeId . trim ( ) ,
196230 region : input . region ,
231+ cloudProvider : context . cloudProvider ,
197232 } ) ,
198233 commitMessage : "feat: publish Agent to AgentKit Runtime" ,
199234 } ,
200235 ] ,
201236 branchPrefix : "feat/agentkit-release" ,
202237 title : "feat: 持续发布到 AgentKit Runtime" ,
203- description : " 新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 Volcengine Secrets。" ,
238+ description : ` 新增 GitHub Actions 工作流,在目标分支更新时持续发布到 AgentKit Runtime。合并前请配置工作流所需的 ${ providerName } Secrets。` ,
204239 } ,
205240 signal ,
206241 ) ;
0 commit comments