Skip to main content

Run Toggly CLI from GitHub Actions

Use the ops-ai/toggly-action composite action to install a pinned toggly-cli release in your workflow and run the same commands you would run locally.

This page covers your pipeline calling Toggly. If you need the opposite direction — Toggly dispatching a workflow when a flag changes — see GitHub Actions Integration.

What it does​

  1. Downloads the cli-v* asset that matches the runner OS and architecture.
  2. Verifies the file against SHA256SUMS from the same release.
  3. Runs toggly-cli with the arguments you supply (quote-aware argv; not via bash -c).

The action does not call the Toggly HTTP API and does not start device-code login.

Pin rule​

Always set version to an exact MAJOR.MINOR.PATCH that exists as a cli-v* release (for example 0.2.1 → tag cli-v0.2.1). Do not use latest.

Secrets​

Store client credentials as GitHub Actions secrets and pass them as environment variables. Do not put secrets in args.

VariableRequiredPurpose
TOGGLY_CLIENT_IDyesOAuth2 client ID
TOGGLY_CLIENT_SECRETyesOAuth2 client secret
TOGGLY_BASE_URLnoOverride API base URL
TOGGLY_AUTHORITYnoOverride auth authority

Examples below use flags verified against toggly-cli 0.2.1.

Recipe 1: Enable a flag after deploy​

- name: Enable feature in Production
uses: ops-ai/toggly-action@v1
with:
version: "0.2.1"
args: >-
update-feature-environment
--application-id my-app
--environment Production
--feature-key my-feature
--enable
env:
TOGGLY_CLIENT_ID: ${{ secrets.TOGGLY_CLIENT_ID }}
TOGGLY_CLIENT_SECRET: ${{ secrets.TOGGLY_CLIENT_SECRET }}

Use --disable instead of --enable to turn the feature off.

Recipe 2: Create a release​

- name: Create Toggly release
uses: ops-ai/toggly-action@v1
with:
version: "0.2.1"
args: >-
create-release
--application-id my-app
--name "Build ${{ github.run_number }}"
--release-notes "Shipped from ${{ github.ref_name }}"
env:
TOGGLY_CLIENT_ID: ${{ secrets.TOGGLY_CLIENT_ID }}
TOGGLY_CLIENT_SECRET: ${{ secrets.TOGGLY_CLIENT_SECRET }}

Recipe 3: Associate the build​

- name: Associate build with release
uses: ops-ai/toggly-action@v1
with:
version: "0.2.1"
args: >-
associate-build
--project-key my-app
--environment Production
--ci-provider github
--run-id ${{ github.run_id }}
--pipeline-name "${{ github.workflow }}"
--branch ${{ github.ref_name }}
--commit-sha ${{ github.sha }}
--build-number ${{ github.run_number }}
--run-url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
TOGGLY_CLIENT_ID: ${{ secrets.TOGGLY_CLIENT_ID }}
TOGGLY_CLIENT_SECRET: ${{ secrets.TOGGLY_CLIENT_SECRET }}