Workflow Running Modes¶
Workflow Running Modes refer to a mechanism for controlling the behavior of a single workflow file, allowing it to perform different actions or processes depending on the context of the execution.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md] Instead of creating separate workflows for similar tasks, a single workflow can listen for multiple trigger events and dynamically alter its execution path based on a specific command or parameter included in the event payload.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md]
Implementation¶
This approach typically utilizes a workflow that listens for an array of event types, such as repository_dispatch events.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md] The specific mode is determined by a value passed in the body of the dispatch event, rather than relying solely on the event type itself.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md] While the workflow could technically listen to a single event type, defining multiple events allows for greater flexibility in how the workflow is invoked.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md]
Example Use Case¶
In the provided "all-in-one" example, a single workflow supports three distinct running modes^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md]:
- Ping: Triggers the workflow and provides the "Pong" command.
- Pong: Triggers the workflow and provides the "Done" command.
- Done: Outputs a completion message.
This contrasts with a "multiple workflows" architecture, where separate workflow files (e.g., Ping, Pong, Done) trigger one another sequentially.^[400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md]
Related Concepts¶
- [[Repository Dispatch]]
- GitHub Actions
- Documentation Workflow
Sources¶
400-devops__04-CI-CD-Pipelines__devops-ci__github-action__README.md