feat(workflows): add auto-disable feature for workflows on consecutive failures
Deploy to Raspberry Pi / deploy (push) Canceled after 0s

- Introduced `disableOnConsecutiveFailures` option in workflow triggers to automatically disable workflows after reaching a specified failure threshold.
- Updated related functions to handle the new feature, including persistence of the disabled state and reloading of registries.
- Enhanced UI components to support the new option, allowing users to toggle the auto-disable feature in the workflow configuration.
This commit is contained in:
2026-08-21 05:37:24 +07:00
parent 46aa8ca327
commit 864427b45c
6 changed files with 113 additions and 12 deletions
+15 -1
View File
@@ -144,6 +144,7 @@ export function newHttpTrigger() {
unauthorized: null,
onConsecutiveFailures: "",
onFailureWorkflow: "",
disableOnConsecutiveFailures: false,
};
}
@@ -159,6 +160,7 @@ export function newCronTrigger() {
unauthorized: null,
onConsecutiveFailures: "",
onFailureWorkflow: "",
disableOnConsecutiveFailures: false,
};
}
@@ -174,6 +176,7 @@ export function newWorkflowTrigger() {
unauthorized: null,
onConsecutiveFailures: "",
onFailureWorkflow: "",
disableOnConsecutiveFailures: false,
};
}
@@ -271,9 +274,16 @@ function normalizeTrigger(raw) {
"unauthorized",
"onConsecutiveFailures",
"onFailureWorkflow",
"disableOnConsecutiveFailures",
])
: type === "cron"
? new Set(["type", "schedule", "onConsecutiveFailures", "onFailureWorkflow"])
? new Set([
"type",
"schedule",
"onConsecutiveFailures",
"onFailureWorkflow",
"disableOnConsecutiveFailures",
])
: new Set(["type"]);
/** @type {Record<string, unknown>} */
const extra = {};
@@ -291,6 +301,7 @@ function normalizeTrigger(raw) {
? ""
: String(raw.onConsecutiveFailures),
onFailureWorkflow: readOnFailureWorkflow(raw),
disableOnConsecutiveFailures: raw.disableOnConsecutiveFailures === true,
auth: Array.isArray(raw.auth) ? raw.auth : null,
response: typeof raw.response === "string" ? raw.response : "",
unauthorized: raw.unauthorized ?? null,
@@ -334,6 +345,9 @@ function dumpFailureTriggerFields(t, out) {
if (typeof t.onFailureWorkflow === "string" && t.onFailureWorkflow.trim()) {
out.onFailureWorkflow = t.onFailureWorkflow.trim();
}
if (t.disableOnConsecutiveFailures === true) {
out.disableOnConsecutiveFailures = true;
}
}
function dumpTrigger(t) {