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
13 changes: 11 additions & 2 deletions config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ sync:
# failures on your own PR branches, drop
# default-branch syncs and scheduled runs.
# Repositories you follow without taking part in them: new PRs, issues and
# releases there. Nothing is set on the GitHub account. With
# releases there, and with the commit type the new commits on a branch (one
# record per branch; useful to gate a job on new commits, see docs/cron.md
# "messages"). Nothing is set on the GitHub account. With
# sync.github.mode: hosted the channel gateway polls them too (it must know
# the repository watch). Nothing older than a day is backfilled: a check
# more than a day after the last (a daily schedule, an outage) reports the
Expand All @@ -366,7 +368,14 @@ sync:
enabled: false
schedule: "*/15 * * * *" # poll mode; hosted: the fallback drain
repos: [] # Required: ["acme/widgets"], each once, at most 50
# types: [pull_request, issue] # pull_request | issue | release
# types: [pull_request, issue] # pull_request | issue | release | commit
# (hosted: commit only once the gateway
# knows the type, see docs/sources.md)
# branches: # commit type: the branches to follow, by
# acme/widgets: [main] # repository; no entry = its default branch.
# A branch's name, not a ref (main, not
# refs/heads/main); quote a name that YAML
# reads as something else: "1.10"
# include_bots: false # also PRs and issues a GitHub App or a [bot]
# opened; releases arrive whoever published them
# include_drafts: true # false: a draft PR is reported when it is
Expand Down
3 changes: 2 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2195,7 +2195,8 @@ reload:
| `sync.github_repos.enabled` | bool | `false` | Enable the repository watch. In hosted mode Nerve publishes it to the gateway only while it is on and `repos` lists a repository |
| `sync.github_repos.schedule` | cron | `*/15 * * * *` | Poll frequency; in hosted mode the fallback cadence of the drain, which also runs on every delivery |
| `sync.github_repos.repos` | list | `[]` | `owner/repo` names as GitHub writes them, each once (case does not matter), at most 50. While the watch is on, a name GitHub would not take, a repository named twice, or more than 50 refuses to load; while it is off, a warning names them. Empty = nothing is watched. Nothing older than a day is backfilled: a check more than a day after the last one (a daily schedule, an outage, the watch switched off for longer) reports the last day's items, with an hour of grace; in hosted mode, switching the watch off and on starts fresh |
| `sync.github_repos.types` | list | `[pull_request, issue]` | What is reported: `pull_request`, `issue`, `release`. Case does not matter; an unknown type or an empty list refuses to load |
| `sync.github_repos.types` | list | `[pull_request, issue]` | What is reported: `pull_request`, `issue`, `release`, `commit` (the new commits on a branch, one record per branch). Case does not matter; an unknown type or an empty list refuses to load. In hosted mode, name `commit` only once the gateway knows the type (see [sources.md](sources.md#hosted-repository-watch)) |
| `sync.github_repos.branches` | map | `{}` | With the `commit` type: the branches whose new commits are reported, as `owner/repo: [branch, …]` for a repository of `repos`, at most 8 each; a repository without an entry reports its default branch. An entry is a branch's name, not a ref (`main`, not `refs/heads/main`), and a name that YAML reads as something else goes in quotes (`"1.10"`). While the watch is on, a value that is not such a map (`branches: [main]`, `branches: []`), a branch that is not a string, a branch name the watch cannot follow, a branch named twice, more than 8, or a repository that `repos` does not list refuses to load (see [sources.md](sources.md#new-commits-on-a-branch)). Without the `commit` type the setting is not read, and a value there is ignored with a warning |
| `sync.github_repos.include_bots` | bool | `false` | Also report the pull requests and issues that a GitHub App or an account whose login ends in `[bot]` opened. A release is reported whoever published it (release automation such as `github-actions[bot]` is the normal case) |
| `sync.github_repos.include_drafts` | bool | `true` | `false`: a draft pull request is reported when it is marked ready for review (event `ready`), not when it is opened |
| `sync.github_repos.updates` | bool | `false` | Also report a new head commit, ready for review, and the merge or close of each pull request the watch reported |
Expand Down
35 changes: 35 additions & 0 deletions docs/cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,41 @@ run_if:
consumer: inbox
```

A job that should run when a branch has new commits needs nothing more than
this gate. Let the [repository watch](sources.md#new-commits-on-a-branch)
report the branch's commits, and gate the job on that source's unread records:

```yaml
# config.yaml
sync:
github_repos:
enabled: true
repos: [acme/widgets]
types: [commit]
branches:
acme/widgets: [main]
```

```yaml
jobs:
- id: on-new-commits
schedule: "*/10 * * * *"
prompt: >
Read the new records with poll_source(source="github_repos",
consumer="on-new-commits"). Each one lists the new commits of a branch.
Then ...
run_if:
- type: messages
sources: [github_repos]
consumer: on-new-commits
```

The job stays idle while the branch does not move. The watch reports one
record per branch however many commits arrive, so one push starts one run,
and reading the records with `poll_source` under the gate's `consumer` marks
them read. The gate looks at the source as a whole: when the watch also
reports pull requests or issues, those records satisfy it too.

Without `sources`, the gate checks the sources on which the consumer has a
cursor. A consumer that reads every source with `poll_all_sources` gets a cursor
on a new source before the source's first run, so the gate sees the first records
Expand Down
Loading