Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Deploy Project
on:
push:
branches: [main]
pull_request:
types: [closed]
branches: [main]

permissions:
Expand Down
31 changes: 13 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
# Prod-Only Event Triggering Example

# Branch-specific event triggering example
Demonstrates how to configure Outerbounds project flows to respond to external
events and schedules, with **only the prod (main branch) version** reacting to
events and schedules, with branch-specific behavior for events,
in this case **only the prod (main branch) version** reacting to
external signals.

## The Pattern
## Quickstart instructions
- Create a GitHub repository
- Create a GitHub Actions machine user in the Outerbounds UI named `prod-event-example-cicd` with info for your GitHub org
- Push this repository to your fork/copy of this repository, you should then see a GitHub action and results of `obproject-deploy`
- Continue [testing](./TESTING.md)

## The pattern in context

| Decorator | Branch behavior | Use when |
|---|---|---|
| `@schedule(cron=...)` | Each branch gets its own CronWorkflow (isolated, cleaned up on teardown) | You want periodic runs |
| `@project_trigger(event=...)` | Sensor scoped to `prj.<project>.<branch>.<event>` — **prod-only by default** when external publishers target the main branch event | External systems should only trigger prod |
| `@trigger_on_finish(flow=...)` | Already branch-scoped — works out of the box | Flow chaining within the same project |
| `@trigger(event=...)` | **NOT** branch-scoped — all branches react to the same event | Avoid for prod-only use cases |
| `@trigger(event=...)` | 🚨 **NOT** branch-scoped — all branches react to the same event | Avoid for branch-specific use cases |

## Flows

Expand All @@ -29,6 +35,7 @@ sensor listens for:

```
prj.prod_event_example.main.external_signal
prj.<project-name>.<branch-name>.<event-name>
```

When deployed on a feature branch `feature/foo`, the sensor listens for:
Expand Down Expand Up @@ -60,16 +67,4 @@ from metaflow.integrations import ArgoEvent
ArgoEvent("prj.prod_event_example.main.external_signal").safe_publish(
payload={"record_count": 100}
)
```

## CI/CD (GitHub Actions)

The `.github/workflows/deploy.yml` deploys on push to main and on PRs:
- **main branch** → creates prod workflow templates, CronWorkflows, and Sensors
- **feature branches** (via PR) → creates isolated test deployments (own schedules, own sensors)
- **branch teardown** (on merge/delete) → removes all branch-specific Argo resources

### Prerequisites

1. Create a GitHub Actions machine user in the Outerbounds UI named `prod-event-example-cicd`
2. Ensure `id-token: write` permission is set (already in the workflow)
```
6 changes: 3 additions & 3 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ from obproject.project_events import ProjectEvent
ProjectEvent(
"external_signal",
project="prod_event_example",
branch="feature_test_isolation",
).safe_publish(payload={"record_count": 999})
branch="feature_test",
).publish(payload={"record_count": 999})
```

### Expected results
Expand All @@ -135,7 +135,7 @@ This confirms full bidirectional isolation.

```bash
git checkout main
obproject-deploy --teardown --branch feature/test-isolation
outerbounds flowproject teardown-branch --id feature/test-isolation
```

### Verify cleanup
Expand Down
Loading