Workflows
Understanding Workflows
In Migraine, workflows and templates serve different but complementary purposes. While templates are the blueprints, workflows are the concrete instances created from these templates with specific configurations and variable values.
Templates vs. Workflows
Templates
- Reusable blueprints
- Define structure and possible actions
- Contain variable placeholders
- Not directly executable
- Shared across team/organization
Workflows
- Concrete instances of templates
- Contains actual variable values
- Directly executable
- Specific to a project/environment
- Stored locally for reuse
Creating Workflows
Workflows are created from templates using the CLI:
Workflow Lifecycle
1. Creation
During creation, you'll:
- Select a template
- Name your workflow
- Provide variable values
- Configure any specific settings
2. Usage
3. Management
Example: Template to Workflow
Original Template
Created Workflow
Key Differences
1. Variable Resolution
- Templates: Contain variable placeholders (
{{VARIABLE_NAME}}
) - Workflows: Contain resolved variable values
2. Storage
- Templates: Stored in template store, shareable
- Workflows: Stored locally in workflow store
3. Execution
- Templates: Cannot be executed directly
- Workflows: Can be run immediately
4. Scope
- Templates: Organization/team-wide
- Workflows: Project/environment specific
5. Reusability
- Templates: Designed for multiple uses
- Workflows: Configured for specific use
Working with Workflows
Running Workflows
Complete Workflow
Specific Actions
With Variable Overrides
Workflow Storage
Workflows are stored in:
- Location:
~/.mg_workflows/
- Format: JSON files
- Naming: Based on workflow ID
Common Workflow Patterns
1. Development Environment
2. Deployment Pipeline
3. Database Operations
Best Practices
1. Workflow Organization
- Use clear, descriptive workflow IDs
- Group related workflows together
- Document workflow purpose and usage
- Keep workflows focused and specific
2. Variable Management
- Store commonly used variables
- Override variables only when needed
- Use environment-specific variables
- Handle sensitive data carefully
3. Workflow Maintenance
- Regularly review and update workflows
- Remove unused workflows
- Keep variable values current
- Test workflows periodically
Troubleshooting
Common Issues
- Workflow Not Found
- Action Not Found
- Variable Errors
Runtime Issues
- Command Failures
- Check variable values are correct
- Verify paths exist
- Ensure required tools are installed
- Check permissions
- Performance Issues
- Review command timeouts
- Check resource usage
- Verify network connectivity
- Monitor disk space
Migration and Backup
Exporting Workflows
- Workflows are stored as JSON
- Can be version controlled
- Easily shareable between teams
- Portable between environments
Backing Up Workflows
Advanced Usage
1. Chaining Workflows
2. CI/CD Integration
Understanding Templates
Templates are the foundation of Migraine workflows. They are JSON-structured documents that define how a sequence of operations should be executed, what checks should be performed, and what actions are available. Templates make workflows reusable, shareable, and version-controlled.
CLI Command Reference
Comprehensive guide to all available CLI commands and their usage.