pyrtan / sourcev0.19.0 · main

pyrtan / examples / github / github-release.toml

1,953 bytes · last changed 2026-10-26 in The catalog grows up: namespaces, publishing by pull request through the gate, gap reports gossiped back to authors; release 0.8.0

1# Latest release of a GitHub repository, from the public API. Shows an
2# optional token from the service's env and a decision on the status code.
3
4name = "github-release"
5version = 2
6namespace = "pyrtan"
7description = "The latest release of a GitHub repository."
8tags = ["github", "read-only"]
9license = "MIT"
10hosts = ["api.github.com"]
11start = "fetch"
12
13[[triggers]]
14pattern = "[what's the] latest release of {repo:word}"
15[[triggers]]
16pattern = "latest {repo:word} release"
17
18[inputs.repo]
19type = "str"
20pattern = "^[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+$"
21description = "owner/name"
22
23[nodes.fetch]
24kind = "observe"
25http = { method = "GET", url = "https://api.github.com/repos/{{ inputs.repo }}/releases/latest", headers = { Accept = "application/vnd.github+json" } }
26into = "resp"
27extract = [
28 { into = "tag", json = "json.tag_name" },
29 { into = "name", json = "json.name" },
30 { into = "published", json = "json.published_at" },
31 { into = "url", json = "json.html_url" },
32 { into = "prerelease", json = "json.prerelease" },
33]
34next = "status"
35
36[nodes.status]
37kind = "decide"
38on = "resp.status"
39branches = [
40 { when = { eq = 200 }, then = "reply" },
41 { when = { eq = 404 }, then = "none" },
42 { when = { in = [403, 429] }, then = "rate-limited" },
43 { else = "unexpected" },
44]
45
46[nodes.reply]
47kind = "done"
48say = "{{ inputs.repo }}: {{ state.tag }} ({{ state.published }}) {{ state.url }}"
49output = { repo = "{{ inputs.repo }}", tag = "{{ state.tag }}", name = "{{ state.name }}", published = "{{ state.published }}", url = "{{ state.url }}", prerelease = "{{ state.prerelease }}" }
50
51[nodes.none]
52kind = "fail"
53reason = "no-release"
54say = "{{ inputs.repo }} has no releases, or does not exist."
55
56[nodes.rate-limited]
57kind = "fail"
58reason = "rate-limited"
59say = "GitHub is rate-limiting unauthenticated requests ({{ state.resp.status }})."
60
61[nodes.unexpected]
62kind = "fail"
63reason = "unexpected-response"
64say = "GitHub answered {{ state.resp.status }}."