/ examples / workflows / yaml-actions-demo.yaml
yaml-actions-demo.yaml
 1  # Example: YAML-Defined Actions (Option B)
 2  #
 3  # Actions defined inline in the workflow — self-contained, portable.
 4  # No external files needed.
 5  #
 6  # Usage:
 7  #   praisonai workflow run yaml-actions-demo.yaml
 8  #   praisonai workflow run yaml-actions-demo.yaml --dry-run
 9  
10  type: job
11  name: yaml-actions-demo
12  description: Demonstrates YAML-defined custom actions
13  
14  # Define reusable actions inline
15  actions:
16    check-python:
17      run: python3 --version
18  
19    count-files:
20      script: |
21        import os
22        cwd = os.getcwd()
23        py_files = [f for f in os.listdir(cwd) if f.endswith('.py')]
24        yaml_files = [f for f in os.listdir(cwd) if f.endswith('.yaml') or f.endswith('.yml')]
25        result = f"Python: {len(py_files)}, YAML: {len(yaml_files)}"
26  
27    timestamp:
28      script: |
29        from datetime import datetime
30        result = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
31  
32  steps:
33    - name: Check Python version
34      action: check-python
35  
36    - name: Count project files
37      action: count-files
38  
39    - name: Get timestamp
40      action: timestamp