Share Rego policy as a GitHub Gist
rego_playground_sharePublish a Rego policy as a secret GitHub Gist to share with teammates or create a reproducible example, returning direct URLs for OPA eval and Conftest, with input/query/data bundled as metadata.
Instructions
Share a Rego policy with teammates or create a reproducible example by publishing it as a GitHub Gist, secret unless public: true is passed, so only people holding the link can read it. Returns { gistUrl, rawPolicyUrl, id, public }: the gistUrl renders the policy with syntax highlighting on github.com; the rawPolicyUrl can be passed directly to OPA (opa eval -d <rawPolicyUrl> <query>) or used as a data source in Conftest. When query, input, or data are supplied, a metadata.json file is bundled into the Gist so recipients have the full evaluation context to reproduce results. Each call creates a new Gist -- use the returned id to reference it later. Requires GITHUB_TOKEN in the environment (GitHub personal access token with the "gist" scope); returns GITHUB_TOKEN_MISSING with setup instructions if unset.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | No | Data document as a JSON string. Stored in metadata.json alongside the policy file. | |
| input | No | Input document as a JSON string. Stored in metadata.json alongside the policy file. | |
| query | No | Default query to evaluate against the policy, e.g. "data.authz.allow". Stored in metadata.json alongside the policy file. | |
| policy | Yes | Rego source code to share (the contents of a .rego file). | |
| public | No | Make the Gist public: listed on the account and searchable. Off by default, which creates a secret Gist that anyone holding the link can read but that is not listed anywhere. | |
| description | No | Short description for the Gist (shown on github.com/gists). |