Docs · Actions

Actions: a job that runs when a save lands

An action is two files in a project, under .interlinked/actions/: a definition (<name>.yml: when it runs, where, what it may read and write, the steps) and the script its steps run. They travel with the project like any other file. When a save that matches arrives in the vault, the run happens on one of your machines, and whatever it writes inside its folders comes back as a new save, made by the action.

Two worked examples, each runnable from an empty project by following its page:

  • A measured LOD chain for Roblox: meshes saved into Characters/ come back as a chain of levels, each rendered and scored against the original. Runs on the maker's machine.
  • Web avatars from any image: images dropped into Avatars/ come back in Web/avatars/ at three sizes, WebP. Runs on the maker's machine, with vips.

The definition, every key

name: LOD chains for meshes          # what lists show; the file's name is what commands take
on:                                  # when it runs: one or more of the five below
  push:                              # a save lands in the vault
    branches: [main]                 #   on these branches (left out: any)
    paths: [Characters/**/*.obj]     #   touching these paths (globs; left out: any)
    kinds: [added, changed]          #   in these ways: added, changed, deleted (left out: all three)
  manual:                            # someone starts it: Run now, `ifile actions run`, the MCP
    inputs:                          #   named values given at the start, each IFILE_INPUT_<NAME>
      quality: { description: "0 to 100", default: "82", required: false }
  schedule: ["0 6 * * 1-5"]          # cron lines, UTC, on the newest save of the default branch
  api: true                          # an outside system may start it: POST /v1/projects/:id/actions/:name/runs
  action: [meshes]                   # after these actions' saves (an action's save sets off nothing else)
runs-on: maker                       # maker | team | <a machine's name> (below)
os: linux                            # only a machine of this system takes the run: windows, mac or linux (left out: any)
shell: bash                          # the shell the steps run in: bash, sh, pwsh or cmd (left out: cmd on Windows, sh elsewhere)
timeout: 60                          # the most minutes a run may take, 1 to 360; past it it is stopped and fails
required: true                       # main takes a save only once this action passed on it (below); needs on: push
needs:
  read: [Characters/**]              # all a run can fetch; nothing else of the project reaches it
  write: [Characters/**/*.lod*.obj]  # all it may change; a change outside fails the run, nothing saved
  tools: [node, npm]                 # checked on the machine before the run
  secrets: [DEPLOY_TOKEN]            # set with `ifile action-secrets set`; reach the steps as environment variables
steps:                               # run in order, in the project's folder; one failing ends the run
  - name: Cut the chain
    run: node .interlinked/actions/lod-chain.mjs
    each: changed                    # once per changed file, its path in FILE
save:
  message: "LOD chain for {count} meshes, worst score {score}"   # {count}: the files that set it off; {key}: a key=value line a step wrote to IFILE_OUTPUT
  to: same-branch                    # the branch it ran on (a branch of the action's own is not built yet)

Every step sees IFILE_ACTION, IFILE_RUN (the run's number), IFILE_BRANCH, IFILE_SAVE and IFILE_SAVE_NUMBER (the save it runs on), IFILE_TRIGGER (push, manual, api, schedule or action), IFILE_CHANGED (the changed paths, one a line), IFILE_OUTPUT (a file for key=value lines) and CI=true, the secrets its definition names, and of the machine's own environment only what a program needs to start (PATH, HOME, TEMP and the like): never its owner's cloud keys or tokens. Nothing under .interlinked/ is ever a run's to change. A definition that does not check says what is wrong and on which line: ifile actions --in <project> lists every action with its problems, and ifile actions validate fails when one is not valid.

Where it runs

runs-onwherewhen to use it
maker (the default)the machine that pushed the save, right after its pusha solo developer or a small team: the files are already there
teamany machine the project's team switched on as a runnerwork that needs a tool or a GPU only some machines have, or should not depend on who pushed
a machine's namethat one registered machine (ifile runner start --name <name>)exactly one machine holds the licence or the hardware

There is no fourth: nothing runs on our machines, and runs-on: hosted is refused. A run costs nothing, because it runs on your machines. Work that should run on someone else's cloud (Fly, a function, a build service) goes there through a webhook: below, and Action: External on the app's Flow tab.

What a run reads and the save it makes are stored and moved like any other bytes of the project, and its save counts like any other save, on the team's storage, transfer and saves.

Nothing runs on a machine its owner did not switch on. A machine takes runs only after ifile runner start --in <project> (or --team <team> for every project of the team), or Run actions on this computer under Action: Local on the app's Flow tab, and stops when told (ifile runner stop). Switching on is the person's own yes: the open app asks in its own dialog, and a machine with no app takes a one-time code its person makes on the website (ifile runner start --enroll <code>). Opening a link or cloning a project never runs anything.

Who approves a run

A team runner runs the code of every writer of the team's projects, so it takes only what was approved. On any machine but the pusher's own, a run is claimed only once its inputs are approved: the action's needs.read, needs.write and the .interlinked/actions folder, as they stand at that save. The team's owner or an admin approves them with ifile actions approve <name> --in <project> (or Approve in the app), at a branch's tip or one save (--save <id>); a push by the owner or an admin approves what it changed. Until then a run someone else set off, a schedule's, a key's or a chained one waits, and ifile runs says so. A run nobody takes within a day expires.

Secrets

A secret is a named value a run is given as an environment variable, and only when its action names it under needs.secrets. Set it for one project or for every project of a team; it is sealed and never read back, by anyone:

ifile action-secrets set DEPLOY_TOKEN --in <project> --from-env DEPLOY_TOKEN
ifile action-secrets --in <project>

--from-file <path> reads it from a file instead, --team <team> sets it for the team. Never write a secret's value into a file of the project; the definition carries the name alone. Every secret's value is shown as *** in a run's log.

Required on main

required: true makes the action a gate. It then runs on every push to every branch, whatever its branches and paths say, so every save has its chance to pass before it reaches main; and main (the default branch) takes a save, by a push or by a merge, only once each required action has passed on it. A push that would bring main a save that has not passed is refused in words, naming the actions and their state: push to a branch, let them pass there, then bring it to main. With ifile protect, the people and badges who may push or merge into main at all are named too.

What it ran

ifile runs --in <project>
ifile runs log 3 --in <project>
ifile actions run <name> --in <project>

ifile runs lists the run in flight and the one waiting, then what each run was (ok, failed, nothing, expired), its machine, its seconds and the save it made; ifile runs log <n> prints one run's log as its machine reported it. ifile actions run starts one by hand on the tip of the default branch (--branch for another), with its inputs as name=value words. In the app, History marks each save with what its actions did.

Or your own pipe: a webhook and a key

Rather run the work on your own servers, in your own CI? Everything an action does can be done from outside with a webhook and a key:

  1. Hear about the save. Point a webhook at your service: ifile auth webhooks add https://you.example/hooks --project <id> --events version.pushed. Each push sends a signed version.pushed (Standard Webhooks: check webhook-signature against the raw body with your secret, answer 2xx within five seconds, ignore a webhook-id you have seen).
  2. Read what you need. Make a key on the project with project:read and status:write (on your account page, or the team's Keys tab; a key belongs to the project, not to you). Then GET /v1/projects/<id>/tree?at=<revision> lists the files and GET /v1/projects/<id>/archive?at=<revision> streams them as one ZIP; at is the save's revision from the event, v<number>, or head.
  3. Say how it went. POST /v1/projects/<id>/commits/<revision>/statuses and PUT .../reports/<name> put your result on the save, where the app and the site show it.
  4. Save results back. On your server, with a sign-in key in INTERLINKED_TOKEN (made on your account page, for 30 days or a year), the CLI works unattended: ifile clone <link> --all (a folder named for the project, every file in it), change the files, then ifile commit <folder> -m "..." and ifile push <folder>.

The routes are on the API page.