File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { kv } from '@nuxthub/kv'
22import { z } from 'zod'
3+ import { createError } from 'evlog'
34import { getSnapshotRepoConfig , setSnapshotRepoConfig } from '../../utils/sandbox/snapshot-config'
45import { KV_KEYS } from '../../utils/sandbox/types'
56import { requireAdmin } from '../../utils/admin'
@@ -23,11 +24,13 @@ export default defineEventHandler(async (event) => {
2324 const snapshotRepo = body . snapshotRepo . trim ( )
2425 const snapshotBranch = body . snapshotBranch ?. trim ( ) || 'main'
2526
26- const token = await getSnapshotToken ( )
27+ const token = await getSnapshotToken ( snapshotRepo )
2728 if ( ! token ) {
2829 throw createError ( {
29- statusCode : 400 ,
30+ status : 400 ,
3031 message : 'GitHub token not found' ,
32+ why : 'Could not resolve a GitHub token for this repository' ,
33+ fix : 'Ensure your GitHub App is installed on this repository, or set NUXT_GITHUB_TOKEN' ,
3134 } )
3235 }
3336
Original file line number Diff line number Diff line change 11import { getToken , resolveGitHubAuth } from '@savoir/github/server/utils'
22import { getSnapshotRepoConfig } from './sandbox/snapshot-config'
33
4- export async function getSnapshotToken ( ) : Promise < string | undefined > {
4+ export async function getSnapshotToken ( repoPath ?: string ) : Promise < string | undefined > {
55 const config = useRuntimeConfig ( )
6- const snapshotConfig = await getSnapshotRepoConfig ( )
76
87 const auth = resolveGitHubAuth ( config . github )
98 if ( ! auth ) return undefined
109
11- return getToken ( auth , snapshotConfig . snapshotRepo )
10+ const targetRepo = repoPath || ( await getSnapshotRepoConfig ( ) ) . snapshotRepo
11+ return getToken ( auth , targetRepo )
1212}
You can’t perform that action at this time.
0 commit comments