mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-02 09:45:00 +00:00
code: nextjs,frontends,workflow (4 files)
This commit is contained in:
@@ -25,9 +25,6 @@ import {
|
||||
CheckCircle,
|
||||
Warning,
|
||||
Image as ImageIcon,
|
||||
FilmStrip,
|
||||
MusicNote,
|
||||
FileText
|
||||
} from '@phosphor-icons/react'
|
||||
|
||||
interface PackageImportExportProps {
|
||||
|
||||
17
frontends/nextjs/src/lib/github/list-workflow-run-jobs.ts
Normal file
17
frontends/nextjs/src/lib/github/list-workflow-run-jobs.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { Octokit } from 'octokit'
|
||||
|
||||
export async function listWorkflowRunJobs(options: {
|
||||
client: Octokit
|
||||
owner: string
|
||||
repo: string
|
||||
runId: number
|
||||
}) {
|
||||
const { data } = await options.client.rest.actions.listJobsForWorkflowRun({
|
||||
owner: options.owner,
|
||||
repo: options.repo,
|
||||
run_id: options.runId,
|
||||
per_page: 100,
|
||||
})
|
||||
|
||||
return data.jobs
|
||||
}
|
||||
16
frontends/nextjs/src/lib/github/list-workflow-runs.ts
Normal file
16
frontends/nextjs/src/lib/github/list-workflow-runs.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import type { Octokit } from 'octokit'
|
||||
|
||||
export async function listWorkflowRuns(options: {
|
||||
client: Octokit
|
||||
owner: string
|
||||
repo: string
|
||||
perPage: number
|
||||
}) {
|
||||
const { data } = await options.client.rest.actions.listWorkflowRunsForRepo({
|
||||
owner: options.owner,
|
||||
repo: options.repo,
|
||||
per_page: options.perPage,
|
||||
})
|
||||
|
||||
return data.workflow_runs
|
||||
}
|
||||
15
frontends/nextjs/src/lib/github/resolve-github-repo.ts
Normal file
15
frontends/nextjs/src/lib/github/resolve-github-repo.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export function resolveGitHubRepo(params: URLSearchParams) {
|
||||
const ownerParam = params.get('owner')
|
||||
const repoParam = params.get('repo')
|
||||
const owner = (ownerParam && ownerParam.trim()) || process.env.GITHUB_OWNER || 'johndoe6345789'
|
||||
const repo = (repoParam && repoParam.trim()) || process.env.GITHUB_REPO || 'metabuilder'
|
||||
const slugPattern = /^[A-Za-z0-9_.-]+$/
|
||||
|
||||
if (!slugPattern.test(owner) || !slugPattern.test(repo)) {
|
||||
const error = new Error('Invalid GitHub repository owner or repo')
|
||||
;(error as Error & { status?: number }).status = 400
|
||||
throw error
|
||||
}
|
||||
|
||||
return { owner, repo }
|
||||
}
|
||||
Reference in New Issue
Block a user