Skip to content

Commit a4d1eff

Browse files
mastercybclaude
andcommitted
chore: add reusable subgraph-notify workflow + installer script + onboarding docs
Every public subgraph now auto-triggers a cyber rebuild on push via repository_dispatch. Reusable workflow keeps dispatch logic in one place. `nu scripts/add-notify-workflow.nu` installs the caller in new repos. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f209d80 commit a4d1eff

3 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Subgraph notify (reusable)
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
dispatch:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Trigger cyber rebuild
11+
uses: peter-evans/repository-dispatch@v3
12+
with:
13+
token: ${{ secrets.CYBER_DISPATCH_TOKEN }}
14+
repository: cyberia-to/cyber
15+
event-type: content-changed

root/cyber/subgraphs.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,29 @@ the workspace anchor at [[.github]] owns all subgraph concerns. under it, [[.git
1616

1717
cyber itself declares no subgraphs — that concern belongs to the workspace. the authoritative, always-current set is the namespace itself.
1818

19+
## adding a new subgraph
20+
21+
1. add a declaration to `subgraphs/<name>.md` with `visibility: public` (or `private` to exclude from prod build)
22+
2. add `notify-cyber.yml` to the new repo so pushes trigger a rebuild:
23+
24+
```yaml
25+
# .github/workflows/notify-cyber.yml
26+
name: Notify cyber
27+
28+
on:
29+
push:
30+
branches: [master, main]
31+
32+
jobs:
33+
notify:
34+
uses: cyberia-to/cyber/.github/workflows/subgraph-notify.yml@master
35+
secrets: inherit
36+
```
37+
38+
3. add `CYBER_DISPATCH_TOKEN` to the repo's secrets (Settings → Secrets → Actions). the token is a GitHub PAT with `repo` scope on `cyberia-to/cyber`. the org-level secret covers all repos — no per-repo config needed if it is already set at org level.
39+
40+
to add the workflow to all existing repos at once: `nu scripts/add-notify-workflow.nu` from the cyber root. dry-run first with `--dry-run`.
41+
1942
## canonical set
2043

2144
follow [[.github/subgraphs]] for the full list of declarations.

scripts/add-notify-workflow.nu

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env nu
2+
# Adds notify-cyber.yml caller workflow to all public subgraph repos.
3+
# Run from cyber/ root: nu scripts/add-notify-workflow.nu [--dry-run]
4+
5+
def parse_field [content: string, field: string] {
6+
let matches = ($content | lines | where {|l| $l | str starts-with $"($field):"})
7+
if ($matches | is-empty) { return "" }
8+
$matches | first | str replace $"($field):" "" | str trim
9+
}
10+
11+
def main [--dry-run (-n)] {
12+
let base = ($env.HOME | path join "cyberia-to")
13+
let caller = "name: Notify cyber
14+
15+
on:
16+
push:
17+
branches: [master, main]
18+
19+
jobs:
20+
notify:
21+
uses: cyberia-to/cyber/.github/workflows/subgraph-notify.yml@master
22+
secrets: inherit"
23+
24+
let subgraphs = (glob subgraphs/*.md | each {|f|
25+
let content = (open --raw $f)
26+
let name = (parse_field $content "name")
27+
let repo = (parse_field $content "repo")
28+
let visibility = (parse_field $content "visibility")
29+
let archived = (parse_field $content "archived")
30+
let orphan = (parse_field $content "orphan")
31+
let local_only = (parse_field $content "local-only")
32+
{
33+
name: $name,
34+
repo: (if $repo == "" { $name } else { $repo }),
35+
visibility: (if $visibility == "" { "public" } else { $visibility }),
36+
archived: ($archived == "true"),
37+
orphan: ($orphan == "true"),
38+
local_only: ($local_only == "true"),
39+
}
40+
} | where {|s| $s.name != "" and $s.name != "cyber" and $s.visibility != "private" and $s.archived != true and $s.orphan != true and $s.local_only != true })
41+
42+
for s in $subgraphs {
43+
let repo_path = ($base | path join $s.repo)
44+
let workflow_dir = ($repo_path | path join ".github" "workflows")
45+
let workflow_file = ($workflow_dir | path join "notify-cyber.yml")
46+
47+
if not ($repo_path | path exists) {
48+
print $" skip ($s.repo): not checked out locally"
49+
continue
50+
}
51+
52+
if ($workflow_file | path exists) {
53+
print $" ok ($s.repo): already has notify-cyber.yml"
54+
continue
55+
}
56+
57+
if $dry_run {
58+
print $" add ($s.repo): would create ($workflow_file)"
59+
continue
60+
}
61+
62+
mkdir $workflow_dir
63+
$caller | save --force $workflow_file
64+
65+
cd $repo_path
66+
git add .github/workflows/notify-cyber.yml
67+
git commit -m $"chore: add notify-cyber workflow — trigger cyber rebuild on push
68+
69+
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>"
70+
git push origin HEAD
71+
print $" done ($s.repo)"
72+
cd ($base | path join "cyber")
73+
}
74+
75+
print "\nDone."
76+
}

0 commit comments

Comments
 (0)