tenseleyflow/shithub / aafdb74

Browse files

actions/trigger: skip Enqueue for disabled workflows

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
aafdb7482278b946fefb3147cdaaf7e2b83ebc0f
Parents
6d6524f
Tree
34a4195

1 changed file

StatusFile+-
M internal/actions/trigger/enqueue.go 19 0
internal/actions/trigger/enqueue.gomodified
@@ -96,6 +96,11 @@ type Result struct {
9696
 	// looked up via ExternalID) for the workflow's jobs. Order
9797
 	// matches Workflow.Jobs declaration order.
9898
 	CheckRunIDs []int64
99
+	// Skipped is true when the workflow was matched but not enqueued
100
+	// because the operator disabled it via the workflow_disabled
101
+	// table. RunID/RunIndex/CheckRunIDs are zero in this case; the
102
+	// caller's only sensible response is to log + move on.
103
+	Skipped bool
99104
 }
100105
 
101106
 // Enqueue persists a matched workflow as a queued run with all its
@@ -112,6 +117,20 @@ func Enqueue(ctx context.Context, deps Deps, p EnqueueParams) (Result, error) {
112117
 	if err := validateParams(&p); err != nil {
113118
 		return Result{}, err
114119
 	}
120
+	// Honour the per-workflow disable flag (§13 REST). A disabled
121
+	// workflow's events get matched and reach here, then bail out
122
+	// before any run/jobs/check_runs rows are written. Re-enabling
123
+	// (DELETE the row) resumes triggering as normal.
124
+	disabled, err := actionsdb.New().IsWorkflowDisabled(ctx, deps.Pool, actionsdb.IsWorkflowDisabledParams{
125
+		RepoID:       p.RepoID,
126
+		WorkflowFile: p.WorkflowFile,
127
+	})
128
+	if err != nil {
129
+		return Result{}, fmt.Errorf("trigger: check disabled: %w", err)
130
+	}
131
+	if disabled {
132
+		return Result{Skipped: true}, nil
133
+	}
115134
 	concurrencyResolution, err := concurrency.Resolve(concurrency.ResolveInput{
116135
 		Workflow:     p.Workflow,
117136
 		EventPayload: p.EventPayload,