#!/usr/bin/env bash # Locked-down label helper for the Marvin triage workflow. # # Marvin runs on untrusted issue/PR bodies from non-write users, so it must # NOT be handed raw `gh api` (that would expose every endpoint the app token # can reach). This helper is the ONLY GitHub write it is allowed to perform: # it adds or removes repository labels on the one issue/PR being triaged. # # The target repo and number come from the environment set by the workflow — # never from the model — and the operation is fixed to the additive labels # endpoint (POST/DELETE /repos/{repo}/issues/{n}/labels), which works for both # issues and PRs and cannot clobber labels applied by other workflows. set -euo pipefail repo="${TRIAGE_REPO:?TRIAGE_REPO not set}" number="${TRIAGE_NUMBER:?TRIAGE_NUMBER not set}" if [[ ! "$number" =~ ^[0-9]+$ ]]; then echo "TRIAGE_NUMBER must be numeric, got: $number" >&2 exit 1 fi op="${1:-}" shift || true case "$op" in add) method=POST ;; remove) method=DELETE ;; *) echo "usage: triage-label.sh