mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 23:25:18 +00:00
- deploy.yml: trigger push em main + preflight guard (pula se há run queued/in_progress; waiting não conta) e job hosted requeue após deploy-staging (fora do grupo deploy-homeserver) - scripts/lib/deploy-trigger.mjs (decidePreflight/decideRequeue) + CLIs deploy-preflight/deploy-requeue; github-api ganha listWorkflowRuns/getBranchHead - pins: ciSkipInvariants reescrito (push + guard + dispatch + requeue fora do grupo), deployTrigger/githubApi novos; deployScript intocado - docs realinhados (AGENTS*, AGENT-OPS, README, runbook, rules/skills) + changelog Closes #980
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
/**
|
|
* Plain-Node CLI (no pnpm) — OPS104 trigger 2. Runs hosted after a green
|
|
* `deploy-staging`: if `main` advanced while the run was in flight, dispatch
|
|
* a new `deploy.yml` from the new head. `workflow_dispatch` is the documented
|
|
* anti-recursion exception, so the built-in `GITHUB_TOKEN` (`actions: write`)
|
|
* suffices — no PAT.
|
|
*
|
|
* Fail-red (OPS104 D6): a failure here would leave staging stale in silence —
|
|
* exit 1 makes it visible (the operator re-dispatches by hand).
|
|
*
|
|
* node scripts/deploy-requeue.mjs
|
|
*/
|
|
|
|
import { decideRequeue } from './lib/deploy-trigger.mjs'
|
|
import { createApi } from './lib/github-api.mjs'
|
|
|
|
const main = async () => {
|
|
const runSha = process.env.GITHUB_SHA
|
|
const api = createApi({})
|
|
const head = await api.getBranchHead('main')
|
|
if (!head?.sha) {
|
|
throw new Error('head de main não encontrado — requeue não verificado')
|
|
}
|
|
const verdict = decideRequeue({ runSha, headSha: head.sha })
|
|
if (verdict.reason === 'sha-ausente') {
|
|
throw new Error(`SHA do run ausente (GITHUB_SHA) — requeue não verificado`)
|
|
}
|
|
if (!verdict.dispatch) {
|
|
console.log(`[deploy-requeue] ${verdict.reason} — sem dispatch`)
|
|
return
|
|
}
|
|
await api.workflowDispatch('deploy.yml', { ref: 'main' })
|
|
console.log(`[deploy-requeue] main avançou (${runSha} → ${head.sha}) — deploy.yml re-dispatchado`)
|
|
}
|
|
|
|
try {
|
|
await main()
|
|
} catch (error) {
|
|
console.error(`[deploy-requeue] falhou: ${error instanceof Error ? error.message : error}`)
|
|
process.exit(1)
|
|
}
|