Skip to content

GitHub Actions

Overview

This page covers how to check out Britive profiles from within GitHub Actions workflows so that jobs receive short-lived cloud credentials at runtime instead of using long-lived secrets stored in GitHub.

The two supported methods are:

MethodWhen to Use
Britive CLI (PyBritive)Standard approach for most workflows — simple shell steps, matrix jobs, reusable workflows
REST APIWhen you need more control over the response, or are calling from a non-shell context (e.g. a JavaScript action) — see the Britive API documentation

Prerequisites

Before adding Britive to a GitHub Actions workflow, ensure the following are in place:

RequirementDetails
Britive service identityCreate a service identity in the Britive console; generate a token
Britive profileThe profile must be active, have an expiration set, and have a policy granting the service identity access
GitHub repository secretsStore BRITIVE_API_TOKEN and BRITIVE_TENANT as encrypted repository or organization secrets
Britive CLI (if using CLI method)PyBritive must be installed in the runner environment, or added as a workflow step

Environment Variables

These variables must be available to the Britive CLI or API call in the workflow job.

VariableRequiredWhere to SetDescription
BRITIVE_API_TOKENYesGitHub encrypted secretService identity token — PyBritive reads this automatically
BRITIVE_TENANTYesGitHub encrypted secretBritive tenant subdomain (see Finding Your Tenant Name)
BRITIVE_PROFILENoWorkflow env blockProfile to check out, as Application/Environment/Profile

CLI Usage

Installing the CLI

Add a step to your workflow to install PyBritive before any checkout step. Pin the version so runner builds are reproducible:

.github/workflows/example.yml
- name: Install PyBritive
  run: pip install pybritive==2.3.2   # pin to your tested version

Checkout Command

pybritive checkout with -m env-nix prints export statements; eval them in the same run: block, then use the credentials:

.github/workflows/example.yml
- name: Check out Britive profile and deploy
  env:
    BRITIVE_API_TOKEN: ${{ secrets.BRITIVE_API_TOKEN }}
    BRITIVE_TENANT: ${{ secrets.BRITIVE_TENANT }}
  run: |
    eval "$(pybritive checkout "AWS Production/Prod Account/ci-deploy" -m env-nix)"
    aws sts get-caller-identity

pybritive checkout Flags

FlagRequiredDefaultDescription
PROFILE (argument)YesProfile as application name/environment name/profile name
-m, --modeNotextOutput mode: env-nix (shell exports), json, integrate (write AWS credentials file), awscredentialprocess, gcloudauth, azlogin, and more
-j, --justificationNoJustification string if the profile policy requires one
-b, --blocktimeNo3 / 60Seconds to wait before polling for credentials (60 for approval-gated profiles)
-a, --aliasNoSave an alias for shorter future checkouts
--ticket-type / --ticket-idNoITSM ticket details if the profile requires a ticket

Variables exported with eval exist only in that run: block’s shell. To pass credentials to later steps, append them to $GITHUB_ENV — and call echo "::add-mask::$VALUE" on each secret value first so they never appear in logs.


REST API Usage

Use the Britive REST API directly when calling from a JavaScript action, Docker container action, or any context without a shell. Authenticate with the service identity token in the Authorization: TOKEN <token> header. See the Britive API documentation for endpoint details.


Injecting Credentials into Subsequent Steps

After a successful checkout, cloud credentials need to be available to the steps that follow. The variables depend on the target cloud:

CloudCredential Variables Injected
AWSAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
GCPGOOGLE_APPLICATION_CREDENTIALS (path to a temp credentials file)
AzureAZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID
SnowflakeSNOWFLAKE_USER, SNOWFLAKE_PASSWORD, SNOWFLAKE_ACCOUNT

Security Considerations

PracticeWhy It Matters
Use ::add-mask:: for secret valuesPrevents credentials from appearing in workflow logs
Scope service identity to minimum profilesLeast-privilege: the service identity should only access profiles it needs
Set short expiration durationsMatch the checkout duration to the job’s expected runtime
Use environment-level secrets for prodGitHub environment protection rules add an approval gate before secrets are exposed

Related

Last updated on