|
28 | 28 | description: GitHub login that requested staging |
29 | 29 | required: true |
30 | 30 | type: string |
| 31 | + comment-id: |
| 32 | + description: Existing InferenceX acknowledgment comment to update |
| 33 | + required: false |
| 34 | + type: string |
31 | 35 |
|
32 | 36 | permissions: {} |
33 | 37 |
|
|
45 | 49 | run-date: ${{ steps.request.outputs.run-date }} |
46 | 50 | pr-number: ${{ steps.request.outputs.pr-number }} |
47 | 51 | requested-by: ${{ steps.request.outputs.requested-by }} |
| 52 | + comment-id: ${{ steps.request.outputs.comment-id }} |
48 | 53 | steps: |
49 | 54 | - name: Validate request payload |
50 | 55 | id: request |
|
54 | 59 | RUN_DATE: ${{ github.event.client_payload.run-date || inputs.run-date }} |
55 | 60 | PR_NUMBER: ${{ github.event.client_payload.pr-number || inputs.pr-number }} |
56 | 61 | REQUESTED_BY: ${{ github.event.client_payload.requested-by || inputs.requested-by }} |
| 62 | + COMMENT_ID: ${{ github.event.client_payload.comment-id || inputs.comment-id }} |
57 | 63 | SOURCE_REPOSITORY: ${{ github.event.client_payload.source-repository || 'SemiAnalysisAI/InferenceX' }} |
58 | 64 | run: | |
59 | 65 | if [[ ! "$RUN_ID" =~ ^[0-9]+$ ]]; then |
|
76 | 82 | echo "::error::requested-by is not a valid GitHub login" |
77 | 83 | exit 1 |
78 | 84 | 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 |
79 | 89 | if [ "$SOURCE_REPOSITORY" != "SemiAnalysisAI/InferenceX" ]; then |
80 | 90 | echo "::error::Unsupported source repository: $SOURCE_REPOSITORY" |
81 | 91 | exit 1 |
|
87 | 97 | echo "run-date=$RUN_DATE" |
88 | 98 | echo "pr-number=$PR_NUMBER" |
89 | 99 | echo "requested-by=$REQUESTED_BY" |
| 100 | + echo "comment-id=$COMMENT_ID" |
90 | 101 | } >> "$GITHUB_OUTPUT" |
91 | 102 |
|
92 | 103 | sync-staging-branch: |
@@ -217,41 +228,30 @@ jobs: |
217 | 228 | runs-on: ubuntu-latest |
218 | 229 | permissions: {} |
219 | 230 | steps: |
220 | | - - name: Comment on source pull request |
| 231 | + - name: Dispatch result to source repository |
221 | 232 | uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
222 | 233 | env: |
223 | 234 | RUN_ID: ${{ needs.validate.outputs.run-id }} |
224 | 235 | RUN_DATE: ${{ needs.validate.outputs.run-date }} |
225 | 236 | PR_NUMBER: ${{ needs.validate.outputs.pr-number }} |
226 | 237 | 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 }} |
228 | 239 | STAGE_SUCCEEDED: ${{ needs['sync-staging-branch'].result == 'success' && needs['refresh-staging-database'].result == 'success' && needs.ingest.result == 'success' }} |
229 | 240 | with: |
230 | 241 | github-token: ${{ secrets.INFX_MAIN_PAT }} |
231 | 242 | 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({ |
253 | 244 | owner: 'SemiAnalysisAI', |
254 | 245 | 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 | + }, |
257 | 257 | }); |
0 commit comments