Transcend Docs

Publish policies from git and CI

Validate Policy Engine bundles on every pull request, then publish and activate reviewed versions from GitHub Actions with an approval step.

Keep policies in your repository, check them on every pull request, and publish only what merges to your main branch. For local authoring, see Author and publish policies with the CLI.

The setup has two workflows:

  • Validation runs on every pull request. It needs no credentials, so it is safe for forks.
  • Publish runs on merges to main. It uploads a version, then waits for approval before it activates that version.

Prerequisites

  • A policy workspace with a Permissions bundle, such as transcend/policy/permissions-bundle.
  • Two API keys, created under Developer Tools → API Keys. One key needs the Manage Policy scope. The other needs the Activate Policy scope.
  • Permission to add GitHub Actions secrets and environments in your repository.

1. Add the validation workflow

Run this from the repository root:

transcend policy init --ci

The CLI writes .github/workflows/transcend-policy.yml. The workflow installs pinned versions of OPA, Regal, and the CLI, then runs transcend policy check on each bundle. It has read-only repository access and no secrets.

transcend policy new refreshes this workflow when you add a bundle. Make the Transcend Policy check required in your branch protection rules, so a failing policy cannot merge.

2. Create a protected environment

In your repository settings, create an environment named transcend-policy. Add required reviewers, so a person approves each activation. See Managing environments for deployment.

Add the two API keys as secrets:

SecretScopeWhere
TRANSCEND_POLICY_PUBLISH_KEYManage PolicyRepository secret
TRANSCEND_POLICY_ACTIVATE_KEYActivate Policytranscend-policy environment

The activate key lives only in the protected environment. A job can read it only after a reviewer approves.

3. Add the publish workflow

Save this as .github/workflows/transcend-policy-publish.yml. Use the same CLI and OPA versions as the validation workflow:

name: Publish Transcend Policy

on:
  push:
    branches: [main]
    paths:
      - 'transcend/policy/permissions-bundle/**'

permissions:
  contents: read

concurrency:
  group: transcend-policy-publish
  cancel-in-progress: false

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: open-policy-agent/setup-opa@v2
        with:
          version: '1.18.2'
      - run: npm install --global @transcend-io/cli@13.4.1
      - name: Upload a new version
        env:
          TRANSCEND_API_KEY: ${{ secrets.TRANSCEND_POLICY_PUBLISH_KEY }}
        run: >-
          transcend policy publish transcend/policy/permissions-bundle
          --remote-bundle-name=permissions
          --version="$GITHUB_SHA"
          --description="$GITHUB_REPOSITORY@$GITHUB_SHA"
          --yes

  activate:
    needs: publish
    runs-on: ubuntu-latest
    environment: transcend-policy
    steps:
      - run: npm install --global @transcend-io/cli@13.4.1
      - name: Activate the new version
        env:
          TRANSCEND_API_KEY: ${{ secrets.TRANSCEND_POLICY_ACTIVATE_KEY }}
        run: >-
          transcend policy activate
          --remote-bundle-name=permissions
          --version="$GITHUB_SHA"

The commit SHA is the version label, so each version points to the exact code that produced it. --yes lets the first run create the remote bundle without a prompt. On US hosting, add TRANSCEND_API_URL: https://api.us.transcend.io to both env blocks.

The concurrency group stops two merges from activating out of order.

4. Merge and approve

Merge a pull request that changes the bundle. The publish job uploads the version. The activate job waits for a reviewer in the transcend-policy environment. After approval, the Permissions API starts returning decisions from the new version after a short delay.

Version labels are unique per bundle. If you re-run the whole workflow for the same commit, publish fails because the version exists. Re-run only the activate job instead.

Roll back

Revert the change and merge the revert. The workflow publishes and activates a new version from the reverted code.

For a faster rollback, activate an earlier commit's version from your machine:

transcend policy versions --remote-bundle-name=permissions
transcend policy activate --remote-bundle-name=permissions --version="<earlier commit SHA>"

Then merge a revert, so the next publish does not bring the bad version back.

On this page