Skip to content

Your first action

An action is one JavaScript file. It fetches something, returns what it found (the state), decides whether that deserves a notification, and describes its card. This page builds one step by step: a card with a GitHub repository’s latest release, and a notification when a new one comes out. GitHub’s API needs no key for this.

The reference has the full contract, and the bundled examples are complete, tested actions to copy from.

You need an editor and, for trying things out, the command-line tool from the repository:

Terminal window
scripts/rundown-cli validate my-action.js # does it load, and what does it declare?
scripts/rundown-cli run my-action.js -i key=value
scripts/rundown-cli test my-action.js # plays my-action.fixtures.json
scripts/rundown-cli test my-action.js --watch # again on every save

It runs scripts with the app’s own engine, so what works there works on the phone. See Testing with rundown-cli.

For autocompletion and type checking in VS Code, start the file with:

// @ts-check
/// <reference path="../../sdk/rundown.d.ts" />

In the app’s Actions folder a jsconfig.json does this for you; leave the reference line out there.

// @ts-check
/// <reference path="../../sdk/rundown.d.ts" />
module.exports = class LatestRelease extends Action {
/** @type {ActionMeta} */
static meta = {
apiVersion: 1,
id: "com.example.latest-release",
name: "Latest release",
version: 1,
description: "Shows a GitHub repository's latest release and notifies about new ones.",
icon: { symbol: "shippingbox" },
schedule: { every: "1h", min: "15m" },
permissions: { hosts: ["api.github.com"] },
inputs: {
repo: { type: "string", label: "Repository", placeholder: "owner/name", required: true },
},
notifications: {
newRelease: { label: "New release" },
},
};
  • id is the action’s identity. Keep it forever: installing a file with the same id updates the action, and its items keep their settings.
  • Raise version when you share a new version. (While you develop in the Actions folder it doesn’t matter.)
  • permissions.hosts is all the network the script gets. The import screen shows it to the user.
  • Each input becomes a field in the item’s settings. Each notification type becomes a switch.
/** @param {ActionContext} ctx */
async run(ctx) {
const res = await ctx.http.get(`https://api.github.com/repos/${ctx.inputs.repo}/releases/latest`, {
headers: { Accept: "application/vnd.github+json" },
});
if (res.status === 404) throw new Error(`${ctx.inputs.repo} has no releases (or doesn't exist)`);
if (!res.ok) throw new Error(`GitHub returned HTTP ${res.status}`);
const release = res.json();
return {
tag: release.tag_name,
name: release.name || release.tag_name,
publishedAt: release.published_at,
url: release.html_url,
};
}

The returned object is the new state. It’s saved, handed to onNotify() next to the previous one, and used by summary(). Keep it small (the limit is 64 KB): what the card shows, plus what you compare between runs.

HTTP errors don’t throw; check res.ok. A thrown error fails the run: the card keeps showing the last good summary with your message underneath, and nothing is saved.

/** @returns {NotificationResult} */
onNotify(previous, current, ctx) {
if (!previous || previous.tag === current.tag) return [];
return {
type: "newRelease",
title: `${ctx.inputs.repo} ${current.tag}`,
body: current.name,
url: current.url,
dedupeKey: current.tag,
};
}

previous is null on the first run. The first run only records a baseline; otherwise every new item would start with a notification. dedupeKey makes sure the same release never notifies twice, even if the state flips back and forth. The app also applies the user’s switches, mutes and rate limits.

/** @returns {Summary} */
summary(current, ctx) {
return {
title: ctx.inputs.repo,
subtitle: current.name,
primary: { value: current.tag, label: "latest release" },
blocks: [
{ type: "keyValue", rows: [{ key: "Published", value: { date: current.publishedAt, style: "relative" } }] },
],
url: current.url,
};
}
};

{ date, style: "relative" } is rendered by the app as “3 days ago” and stays current; a string you format yourself would go stale on a card that isn’t refreshed. The @returns {Summary} line matters for type checking: without it, "keyValue" is just a string to the checker.

Terminal window
scripts/rundown-cli run latest-release.js -i repo=swiftlang/swift

run keeps the state in .rundown-state/, so running it again behaves like the second run on the phone (--reset starts over, --dry-run saves nothing).

A fixture file replays recorded responses and checks the results, so the action is tested without the network. Save this as latest-release.fixtures.json:

{
"inputs": { "repo": "octo/hello" },
"runs": [
{
"name": "the first run records the current release",
"http": [{
"request": { "url": "https://api.github.com/repos/octo/hello/releases/latest" },
"response": { "json": { "tag_name": "v1.0", "name": "First", "published_at": "2026-09-01T10:00:00Z", "html_url": "https://github.com/octo/hello/releases/tag/v1.0" } }
}],
"expect": { "notifications": [], "summary": { "primary": { "value": "v1.0" } } }
},
{
"name": "a new tag notifies",
"http": [{
"request": { "url": "https://api.github.com/repos/octo/hello/releases/latest" },
"response": { "json": { "tag_name": "v1.1", "name": "Faster", "published_at": "2026-09-20T10:00:00Z", "html_url": "https://github.com/octo/hello/releases/tag/v1.1" } }
}],
"expect": { "notifications": [{ "type": "newRelease", "title": "octo/hello v1.1", "dedupeKey": "v1.1" }] }
}
]
}
Terminal window
scripts/rundown-cli test latest-release.js --watch

State carries over between runs, like in the app. Expectations are subsets: list only what matters. Fixtures can also record socket conversations, check request headers and change inputs between runs; see Testing with rundown-cli.

Save the file in the app’s Actions folder, or import it from Files, a link or the clipboard (Library › Import). Then add an item with +.

  • rundown-cli validate is clean, and the fixtures cover the first run, a change that notifies, a run that changes nothing, and an error.
  • The first run doesn’t notify, and every notification has a dedupeKey.
  • Error messages tell the user what to do.
  • permissions.hosts is as narrow as it can be. "*" is fine when the URL is an input, but it’s flagged on import.
  • Raise version when you publish a change.