diff --git a/src/constants/opensumi.ts b/src/constants/opensumi.ts index ecdef8a..d9b5411 100644 --- a/src/constants/opensumi.ts +++ b/src/constants/opensumi.ts @@ -24,6 +24,13 @@ export namespace ActionsRepo { ref: 'main', }; + export const CODEBLITZ_PR_NEXT_RELEASE_FILE = 'codeblitz-release-next.yml'; + export const CODEBLITZ_PR_NEXT_WORKFLOW = { + ...info, + workflow_id: CODEBLITZ_PR_NEXT_RELEASE_FILE, + ref: 'main', + }; + export const RELEASE_NEXT_BY_REF = 'release-next-by-ref.yml'; export const RELEASE_NEXT_BY_REF_WORKFLOW = { ...info, diff --git a/src/github/commands/pullRequests/index.ts b/src/github/commands/pullRequests/index.ts index b027bbf..a63bd21 100644 --- a/src/github/commands/pullRequests/index.ts +++ b/src/github/commands/pullRequests/index.ts @@ -24,9 +24,11 @@ export function extractTargetBranchNameFromCommand(str: string) { return; } -const allowedRepo = new Set<string>(['opensumi/core']); +const backportAllowedRepo = new Set<string>(['opensumi/core']); -function constrainRepo(fullname: string) { +const allowedRepo = new Set<string>(['opensumi/core', 'opensumi/codeblitz']); + +function constraintRepo(fullname: string, allowedRepo: Set<string>) { if (!allowedRepo.has(fullname)) { throw new StopError('This command is not allowed in this repository'); } @@ -38,7 +40,7 @@ export function registerPullRequestCommand(it: GitHubCommandCenter) { kBackportKeyword, async (ctx) => { const { app, payload } = ctx; - constrainRepo(payload.repository.full_name); + constraintRepo(payload.repository.full_name, backportAllowedRepo); const { issue } = payload; @@ -102,8 +104,8 @@ Please see: <${getActionsUrl(ActionsRepo.BACKPORT_PR_WORKFLOW)}>`, const { app, payload } = ctx; const owner = payload.repository.owner.login; const repo = payload.repository.name; - - constrainRepo(payload.repository.full_name); + const fullname = payload.repository.full_name; + constraintRepo(fullname, allowedRepo); const user = payload.sender.login; let userHaveWritePerm = await app.octoService.checkRepoWritePermission( @@ -150,6 +152,7 @@ Please see: <${getActionsUrl(ActionsRepo.BACKPORT_PR_WORKFLOW)}>`, await app.opensumiOctoService.prNextRelease({ pull_number: issue.number, + fullname, }); await app.createReactionForIssueComment(ctx, 'eyes'); }); diff --git a/src/github/service/opensumi.ts b/src/github/service/opensumi.ts index 3e6bfca..f961bf2 100644 --- a/src/github/service/opensumi.ts +++ b/src/github/service/opensumi.ts @@ -1,4 +1,4 @@ -import { ActionsRepo, RepoInfo } from '@/constants/opensumi'; +import { ActionsRepo } from '@/constants/opensumi'; import { GitHubService } from '@opensumi/octo-service'; import { firstLine } from '../renderer/line'; @@ -107,9 +107,26 @@ export class OpenSumiOctoService extends GitHubService { return workflow; } - async prNextRelease({ pull_number }: { pull_number: number }) { + async prNextRelease({ + pull_number, + fullname, + }: { + pull_number: number; + fullname: string; + }) { + let workflowInfo: any; + + switch (fullname) { + case 'opensumi/core': + workflowInfo = ActionsRepo.PR_NEXT_WORKFLOW; + break; + case 'opensumi/codeblitz': + workflowInfo = ActionsRepo.CODEBLITZ_PR_NEXT_WORKFLOW; + break; + } + const workflow = await this.octo.actions.createWorkflowDispatch({ - ...ActionsRepo.PR_NEXT_WORKFLOW, + ...workflowInfo, inputs: { pull_number: pull_number.toString(), },