scripts/trigger-triage/README.md
This script triggers the Miriad issue triage workflow for a GitHub issue URL.
It is used by the sanity-io/sanity GitHub workflow and can also be run from
the terminal while developing or testing.
The GitHub Action installs root dependencies and runs the same pnpm issue-triage
scripts as local development via tsx. Use Node 22.18 or newer locally.
Like other helpers under scripts/, this folder is not a workspace package.
There is no local package.json, build output, or install step.
Given a GitHub issue URL, the default CLI path:
automated, dependencies, duplicate, wontfix).{repo}-issue-{number}.@triager.The trigger does not post back to GitHub. It only starts the Miriad workflow.
A separate archive entrypoint handles closed issues. It fetches the issue to apply the same ignore filters as triage, derives the expected channel name from the issue URL, finds that channel in Miriad, and archives it:
pnpm issue-triage:archive https://github.com/sanity-io/sanity/issues/725
The workflow that calls this script is:
.github/workflows/issue-triage.yml
It runs when:
needs-triage label is added to an existing issue.issue_url input.For issue events, the workflow passes github.event.issue.html_url to the CLI.
For manual runs, it passes the issue_url input instead.
pnpm issue-triage --verbose "$ISSUE_URL"
Closed issue events run the archive mode:
pnpm issue-triage:archive --verbose "$ISSUE_URL"
Archive mode calls the Miriad REST API equivalent of:
curl -X POST "$MIRIAD_URL/channels/$CHANNEL_ID/archive" \
-H "Authorization: Bearer $MIRIAD_TOKEN"
To trigger it manually, open the Issue Triage workflow in GitHub Actions, click
Run workflow, and paste a GitHub issue URL such as
https://github.com/sanity-io/sanity/issues/12835.
From the repository root:
pnpm issue-triage https://github.com/sanity-io/sanity/issues/12835
Dry-run mode fetches and filters the issue, then prints the Miriad kickoff message without calling Miriad:
pnpm issue-triage --dry-run https://github.com/sanity-io/sanity/issues/12835
Verbose mode prints debug logs:
pnpm issue-triage --verbose https://github.com/sanity-io/sanity/issues/12835
Archive the Miriad channel for a closed issue:
pnpm issue-triage:archive https://github.com/sanity-io/sanity/issues/12835
Add these to the repository's GitHub Actions secrets:
MIRIAD_URL - Miriad REST API base URL.MIRIAD_TOKEN - Bearer token for the Miriad REST API.MIRIAD_SPACE_ID - Miriad space short id.The workflow sets GITHUB_TOKEN from GitHub's built-in token:
GITHUB_TOKEN: ${{ github.token }}
Do not add a custom GITHUB_TOKEN repository secret for this workflow.
For local terminal runs, GITHUB_TOKEN is optional. Set it only if anonymous
GitHub API requests hit rate limits or if you are testing against a private
repository.
GITHUB_TOKEN=ghp_example pnpm issue-triage --dry-run https://github.com/sanity-io/sanity/issues/725
The script loads local .env files automatically without any extra tooling.
Shell-provided environment variables always win. Put Miriad credentials in either
location:
# Option 1: repository root (already used by other local tooling in this repo)
.env
# Option 2: script-local (keeps triage secrets scoped to this helper)
scripts/trigger-triage/.env
To use the script-local file, copy the example:
cp scripts/trigger-triage/.env.example scripts/trigger-triage/.env
The lookup order is:
scripts/trigger-triage/.env..env.Values from step 1 are never overwritten. Between the two .env files, the
script-local file is loaded first, so its values take precedence over the root
.env for any key defined in both.
The Miriad agents are intentionally hardcoded in src/index.ts:
export const AGENT_NAMES = ['squiggler', 'triager'] as const
This keeps the GitHub workflow and repository settings small: agent assignment
is part of the script behavior, not deployment configuration. If another repo or
Miriad workspace uses different callsigns, update AGENT_NAMES before copying
or enabling the workflow there.
To reuse this setup in another repository:
scripts/trigger-triage/..github/workflows/issue-triage.yml.MIRIAD_URLMIRIAD_TOKENMIRIAD_SPACE_ID
Add these variables to the repository secrets.AGENT_NAMES in src/index.ts and update the callsigns if the target
Miriad workspace uses different agents.github.event.issue.html_url to the CLI.workflow_dispatch input is still named issue_url.needs-triage to
an existing issue.