Skip to content

Commit d18bf92

Browse files
authored
fix: dispatch staging callbacks to InferenceX (#567)
Send staging completion data back through repository_dispatch so InferenceX can update the existing acknowledgment comment with its GitHub Actions bot identity. 中文:将预发布回调分派到 InferenceX。通过 repository_dispatch 回传预发布完成数据,由 InferenceX 使用 GitHub Actions 机器人身份更新现有确认评论。
1 parent 8b65cc2 commit d18bf92

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

.github/workflows/stage-results.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ on:
2828
description: GitHub login that requested staging
2929
required: true
3030
type: string
31+
comment-id:
32+
description: Existing InferenceX acknowledgment comment to update
33+
required: false
34+
type: string
3135

3236
permissions: {}
3337

@@ -45,6 +49,7 @@ jobs:
4549
run-date: ${{ steps.request.outputs.run-date }}
4650
pr-number: ${{ steps.request.outputs.pr-number }}
4751
requested-by: ${{ steps.request.outputs.requested-by }}
52+
comment-id: ${{ steps.request.outputs.comment-id }}
4853
steps:
4954
- name: Validate request payload
5055
id: request
@@ -54,6 +59,7 @@ jobs:
5459
RUN_DATE: ${{ github.event.client_payload.run-date || inputs.run-date }}
5560
PR_NUMBER: ${{ github.event.client_payload.pr-number || inputs.pr-number }}
5661
REQUESTED_BY: ${{ github.event.client_payload.requested-by || inputs.requested-by }}
62+
COMMENT_ID: ${{ github.event.client_payload.comment-id || inputs.comment-id }}
5763
SOURCE_REPOSITORY: ${{ github.event.client_payload.source-repository || 'SemiAnalysisAI/InferenceX' }}
5864
run: |
5965
if [[ ! "$RUN_ID" =~ ^[0-9]+$ ]]; then
@@ -76,6 +82,10 @@ jobs:
7682
echo "::error::requested-by is not a valid GitHub login"
7783
exit 1
7884
fi
85+
if [ -n "$COMMENT_ID" ] && [[ ! "$COMMENT_ID" =~ ^[0-9]+$ ]]; then
86+
echo "::error::comment-id must be numeric when provided"
87+
exit 1
88+
fi
7989
if [ "$SOURCE_REPOSITORY" != "SemiAnalysisAI/InferenceX" ]; then
8090
echo "::error::Unsupported source repository: $SOURCE_REPOSITORY"
8191
exit 1
@@ -87,6 +97,7 @@ jobs:
8797
echo "run-date=$RUN_DATE"
8898
echo "pr-number=$PR_NUMBER"
8999
echo "requested-by=$REQUESTED_BY"
100+
echo "comment-id=$COMMENT_ID"
90101
} >> "$GITHUB_OUTPUT"
91102
92103
sync-staging-branch:
@@ -217,41 +228,30 @@ jobs:
217228
runs-on: ubuntu-latest
218229
permissions: {}
219230
steps:
220-
- name: Comment on source pull request
231+
- name: Dispatch result to source repository
221232
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
222233
env:
223234
RUN_ID: ${{ needs.validate.outputs.run-id }}
224235
RUN_DATE: ${{ needs.validate.outputs.run-date }}
225236
PR_NUMBER: ${{ needs.validate.outputs.pr-number }}
226237
REQUESTED_BY: ${{ needs.validate.outputs.requested-by }}
227-
STAGING_SITE_URL: ${{ vars.STAGING_SITE_URL || 'https://inferencemax-app-git-staging-semianalysisai.vercel.app' }}
238+
COMMENT_ID: ${{ needs.validate.outputs.comment-id }}
228239
STAGE_SUCCEEDED: ${{ needs['sync-staging-branch'].result == 'success' && needs['refresh-staging-database'].result == 'success' && needs.ingest.result == 'success' }}
229240
with:
230241
github-token: ${{ secrets.INFX_MAIN_PAT }}
231242
script: |
232-
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
233-
const site = process.env.STAGING_SITE_URL.replace(/\/$/u, '');
234-
const entry = encodeURIComponent(`${process.env.RUN_DATE}~r${process.env.RUN_ID}`);
235-
const chartUrl = `${site}/inference?i_dates=${entry}`;
236-
const success = process.env.STAGE_SUCCEEDED === 'true';
237-
const body = success
238-
? [
239-
`@${process.env.REQUESTED_BY} staged run ${process.env.RUN_ID}: ${chartUrl}`,
240-
'',
241-
`This shared staging slot remains available until the next \`/stage-results\` request. [Staging workflow](${runUrl})`,
242-
'',
243-
`@${process.env.REQUESTED_BY} 已将运行 ${process.env.RUN_ID} 发布到预发布环境:${chartUrl}`,
244-
'',
245-
`该共享预发布环境会保留到下一次 \`/stage-results\` 请求。[预发布工作流](${runUrl})`,
246-
].join('\n')
247-
: [
248-
`@${process.env.REQUESTED_BY} staging run ${process.env.RUN_ID} failed. [Inspect the staging workflow](${runUrl}).`,
249-
'',
250-
`@${process.env.REQUESTED_BY} 预发布运行 ${process.env.RUN_ID} 失败。[查看预发布工作流](${runUrl})。`,
251-
].join('\n');
252-
await github.rest.issues.createComment({
243+
await github.rest.repos.createDispatchEvent({
253244
owner: 'SemiAnalysisAI',
254245
repo: 'InferenceX',
255-
issue_number: Number(process.env.PR_NUMBER),
256-
body,
246+
event_type: 'stage-results-completed',
247+
client_payload: {
248+
'source-repository': `${context.repo.owner}/${context.repo.repo}`,
249+
'pr-number': process.env.PR_NUMBER,
250+
'run-id': process.env.RUN_ID,
251+
'run-date': process.env.RUN_DATE,
252+
'requested-by': process.env.REQUESTED_BY,
253+
'comment-id': process.env.COMMENT_ID,
254+
'stage-succeeded': process.env.STAGE_SUCCEEDED,
255+
'app-run-id': String(context.runId),
256+
},
257257
});

0 commit comments

Comments
 (0)