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 | |
| 4 | name = "github-release" |
| 5 | version = 2 |
| 6 | namespace = "pyrtan" |
| 7 | description = "The latest release of a GitHub repository." |
| 8 | tags = ["github", "read-only"] |
| 9 | license = "MIT" |
| 10 | hosts = ["api.github.com"] |
| 11 | start = "fetch" |
| 12 | |
| 13 | [[triggers]] |
| 14 | pattern = "[what's the] latest release of {repo:word}" |
| 15 | [[triggers]] |
| 16 | pattern = "latest {repo:word} release" |
| 17 | |
| 18 | [inputs.repo] |
| 19 | type = "str" |
| 20 | pattern = "^[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+$" |
| 21 | description = "owner/name" |
| 22 | |
| 23 | [nodes.fetch] |
| 24 | kind = "observe" |
| 25 | http = { method = "GET", url = "https://api.github.com/repos/{{ inputs.repo }}/releases/latest", headers = { Accept = "application/vnd.github+json" } } |
| 26 | into = "resp" |
| 27 | extract = [ |
| 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 | ] |
| 34 | next = "status" |
| 35 | |
| 36 | [nodes.status] |
| 37 | kind = "decide" |
| 38 | on = "resp.status" |
| 39 | branches = [ |
| 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] |
| 47 | kind = "done" |
| 48 | say = "{{ inputs.repo }}: {{ state.tag }} ({{ state.published }}) {{ state.url }}" |
| 49 | output = { repo = "{{ inputs.repo }}", tag = "{{ state.tag }}", name = "{{ state.name }}", published = "{{ state.published }}", url = "{{ state.url }}", prerelease = "{{ state.prerelease }}" } |
| 50 | |
| 51 | [nodes.none] |
| 52 | kind = "fail" |
| 53 | reason = "no-release" |
| 54 | say = "{{ inputs.repo }} has no releases, or does not exist." |
| 55 | |
| 56 | [nodes.rate-limited] |
| 57 | kind = "fail" |
| 58 | reason = "rate-limited" |
| 59 | say = "GitHub is rate-limiting unauthenticated requests ({{ state.resp.status }})." |
| 60 | |
| 61 | [nodes.unexpected] |
| 62 | kind = "fail" |
| 63 | reason = "unexpected-response" |
| 64 | say = "GitHub answered {{ state.resp.status }}." |