Files
w3ai-flows/git_trigger_flow.py
2025-11-08 01:36:55 +00:00

24 lines
1.0 KiB
Python

# File: git_trigger_flow.py
from prefect import flow, get_run_logger
@flow(name="GitOps Trigger Flow")
def git_triggered_flow(repo_name: str = "unknown repository", commit_sha: str = "unknown commit"):
"""
A simple flow that logs a message indicating it was triggered by a Git push event.
This flow is the target for our GitOps webhook automation.
"""
# get_run_logger() is the standard way to log information in Prefect flows.
# These logs will appear in the `flow.w3ai` UI for the specific flow run.
logger = get_run_logger()
logger.info("🚀 Hello from the GitOps Trigger Flow!")
logger.info(f"Successfully triggered by an update to repository: {repo_name}")
logger.info(f"Commit SHA: {commit_sha}")
logger.info("✅ The Git-to-Flow pipeline is working!")
# This block allows you to run the script directly from the command line for testing.
# It will not be used by the Prefect agent, but it's good practice.
if __name__ == "__main__":
git_triggered_flow(repo_name="w3ai/test-repo", commit_sha="abc123def456")