Analyse: Freischalten, Abschalten, Abo-Pruefung
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e66f55c2c
commit
f0eee196ed
10 files changed
+540
-32
No files matched your search
@@ -0,0 +1,33 @@
|
||||
// Neubau einer Preview/Live-Seite anstossen (WOMS-Preview-Block, Website-Analyse ein/aus)
|
||||
import { getRepoInfo } from './giteaAdmin.js'
|
||||
import { runDeploy, fetchPreviewConfig } from './previewDeploy.js'
|
||||
|
||||
const BUSY = 'Server ausgelastet, versuche es gleich noch mal'
|
||||
|
||||
export async function previewBranchOf(doc) {
|
||||
return doc.previewBranch || (await getRepoInfo(doc.repoFullName).catch(() => null))?.defaultBranch || 'main'
|
||||
}
|
||||
|
||||
// Neubau anstossen (wie beim Bearbeiten/Reaktivieren eines Projekts)
|
||||
export async function triggerRebuild(doc) {
|
||||
const repo = doc.repoFullName
|
||||
const branch = await previewBranchOf(doc)
|
||||
const found = await fetchPreviewConfig(repo, branch).catch(() => null)
|
||||
const cfg = {
|
||||
enabled: true,
|
||||
type: 'static',
|
||||
displayName: doc.projectName,
|
||||
...(found || {}),
|
||||
branch,
|
||||
subdomain: doc.subdomain,
|
||||
}
|
||||
const result = await runDeploy(repo, branch, cfg, { project: doc })
|
||||
// runDeploy meldet Runner-Fehler im Ergebnis; Schutzschalter (503) an WOMS durchreichen
|
||||
if (result?.error && /Server ausgelastet/.test(result.error)) {
|
||||
const err = new Error(BUSY)
|
||||
err.status = 503
|
||||
err.expected = true
|
||||
throw err
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in new issue
Block a user