Skip to content

Workflow Chain Pattern

The Workflow Chain Pattern is a design strategy in automation and CI/CD pipelines where a sequence of discrete workflows are triggered in a specific, relay-like fashion^[github-action__README.md].

Instead of executing a single, monolithic script, the completion of one workflow initiates the next step in the process via event dispatching^[github-action__README.md].

Implementation Mechanisms

The pattern relies on the ability to trigger workflows from separate workflow files or to trigger the same workflow in different running modes^[github-action__README.md].

In systems like GitHub Actions, this is commonly implemented using a Repository Dispatch event^[github-action__README.md].

Variations

Multiple Workflow Chain

This variation involves distinct workflow files, where each triggers the next^[github-action__README.md].

  • Trigger: Workflow A (Ping) listens for an event (e.g., run-ping).
  • Chain: Upon completion, Workflow A triggers Workflow B (Pong) via a dispatch event for type run-pong.
  • Termination: Workflow B subsequently triggers the final Workflow C (Done), which outputs the completion status^[github-action__README.md].

Single Workflow Command Chain

This variation uses a single workflow file that listens for multiple event types to determine the "running mode"^[github-action__README.md].

  • Trigger: The workflow listens for events such as run-ping-allinone.
  • Command Logic: A specific command or parameter is passed in the dispatch event body to define the running mode^[github-action__README.md].
  • Execution: The workflow executes logic based on the provided mode (e.g., Ping mode triggers the next Pong mode) until the sequence is finished^[github-action__README.md].

Sources

^[github-action__README.md]