For syncing secrets from Infisical to GitHub (one-way sync to GitHub Secrets), use our
GitHub Secret Syncs instead.
Concept
The Infisical Secrets Action enables GitHub Actions workflows to fetch secrets from Infisical at runtime using OpenID Connect (OIDC) authentication with machine identities. Instead of storing long-lived credentials in GitHub Secrets, workflows authenticate to Infisical using short-lived OIDC tokens issued by GitHub. This eliminates the need for static API keys or tokens while providing fine-grained access control based on repository, workflow, and execution context. Secrets are fetched dynamically during workflow execution and exposed as environment variables, existing only for the lifetime of the job. This approach centralizes secret management in Infisical while maintaining security through identity-based authentication. The short video below provides a guided overview of using Infisical with GitHub Actions and OIDC authentication, helping you build the right mental model before diving into the diagram and setup steps.Diagram
The following sequence diagram illustrates the OIDC authentication workflow. The authentication flow is the same for all OIDC providers; for GitHub Actions, the client is a GitHub workflow and the identity provider is GitHub’s OIDC service.In GitHub Actions, the Infisical Secrets Action handles steps 1-2 and 5, automatically fetching secrets after authentication and injecting them as environment variables into your workflow.
Workflow
A typical workflow for using Infisical with GitHub Actions consists of the following steps:- Create a machine identity in Infisical with OIDC authentication configured for your GitHub repository and workflow context.
- Add the machine identity to your Infisical project with appropriate permissions to access the required secrets.
- Configure your GitHub Actions workflow to use the Infisical Secrets Action with OIDC authentication.
- The workflow authenticates using GitHub’s OIDC token, fetches secrets from Infisical, and exposes them as environment variables for the duration of the job.
How It Works
GitHub Actions uses OpenID Connect (OIDC) to authenticate workflows without storing long-lived credentials. At a high level, the flow looks like this:-
GitHub Issues an OIDC Token
When a workflow starts, GitHub issues a short-lived OIDC token containing identity claims about the repository, workflow, and execution context. -
Workflow Presents Its Identity
The Infisical Secrets Action sends this token to Infisical as proof of the workflow’s identity. -
Infisical Verifies Trust
Infisical validates the token signature using GitHub’s OIDC provider and checks the token’s subject, audience, and claims against the configured machine identity. -
Secrets Are Issued at Runtime
If the identity matches, Infisical issues a short-lived access token. The action then uses this token to fetch only the secrets the identity is authorized to access for the requested project and environment.
Prerequisites
Before you begin, ensure you have:- An Infisical project (Infisical Cloud or self-hosted instance)
- Secrets stored in your Infisical project
- A GitHub repository with Actions enabled
Guide
In the following steps, we explore how to configure GitHub Actions to authenticate with Infisical using OIDC and fetch secrets at runtime.Configure secrets in Infisical
Ensure the secrets your workflow needs are stored in your Infisical project and environment (e.g.,
dev, staging, prod).For example, a pipeline that builds and pushes a Docker image might require:DOCKER_USERNAMEDOCKER_PASSWORD
Secrets are scoped to an environment. Ensure they exist in the environment your workflow will access.
Create a machine identity with OIDC authentication
A machine identity represents a non-human workload (such as a CI/CD pipeline, server, or automated job) and defines what that workload is authorized to access without being tied to a user account.To create a machine identity with OIDC authentication:
- Navigate to your project in Infisical
- Go to your project > Access Control > Machine Identities
- Click Add Machine Identity to Project
- Provide a name for the identity (e.g.,
github-actions-workflow) - Select an organization-level role that defines what the identity can access
- Click Create
Configure OIDC authentication
- Click on your machine identity
- Remove the default Universal Auth configuration
- Click Add auth method and select OIDC Auth
-
OIDC Discovery URL:
https://token.actions.githubusercontent.com -
Issuer:
https://token.actions.githubusercontent.com - CA Certificate: Leave blank for GitHub Actions
-
Subject: The expected principal that is the subject of the JWT. The format is:
For example:
repo:octocat/example-repo:ref:refs/heads/main(specific branch)repo:octocat/example-repo:environment:production(specific environment)repo:octocat/example-repo:*(any context in the repository)
-
Audiences: A list of intended recipients. Set this to your GitHub organization URL, for example:
https://github.com/octo-org - Claims: (Optional) Additional attributes that should be present in the JWT. Refer to GitHub’s OIDC token documentation for supported claims.
Together, the Subject and Audience settings make the trust relationship explicit. Only workflows that match the repository, context, and audience you’ve defined will be able to authenticate and fetch secrets.
Copy the identity ID
After configuring OIDC authentication, Infisical provides an Identity ID. This is what you’ll reference in your GitHub Actions workflow.Copy this value — you’ll need it in the next step.
The Identity ID is not a secret. It’s a public identifier that’s safe to commit directly into your workflow YAML files.
Configure GitHub Actions Workflow
Now let’s configure your GitHub Actions workflow to fetch secrets from Infisical.Basic Workflow Example
Create or update a workflow file in.github/workflows/ (e.g., .github/workflows/infisical-demo.yml):
Key Configuration Points
Permissions Block: Theid-token: write permission is required for OIDC authentication. Without it, GitHub won’t issue an OIDC token for the workflow run.
Infisical Secrets Action: The Infisical Secrets Action step handles:
- Requesting the OIDC token from GitHub
- Authenticating with Infisical using OIDC
- Fetching secrets for the specified project and environment
- Injecting secrets as environment variables
method: "oidc"- Specifies OIDC authenticationidentity-id- The machine identity ID from Infisical (safe to commit)project-slug- Your Infisical project slug (found in project settings)env-slug- The environment to fetch secrets from (e.g.,dev,staging,prod)
This workflow uses OIDC authentication with short-lived tokens. The
identity-id is a public identifier that can be safely committed to your repository.
Authentication occurs at runtime using GitHub’s OIDC token, eliminating the need to store long-lived credentials.Using Secrets in Workflows
After the Infisical Secrets Action completes, secrets are available as environment variables for subsequent steps in the job. Reference them using standard environment variable syntax:Troubleshooting
Authentication Failures
If authentication fails, check:- Permissions: Ensure
id-token: writeis set in the workflow permissions - Subject Match: Verify the Subject in your machine identity matches the repository and context
- Audience Match: Confirm the Audience matches your GitHub organization
- Identity Scope: Ensure the identity has access to the project and environment you’re requesting
- Project Slug: Verify the
project-slugmatches your Infisical project slug exactly. You can find this in your project settings. - Environment Slug: Confirm the
env-slugmatches the exact environment name in Infisical (e.g.,dev,staging,prod). Environment slugs are case-sensitive and must match exactly.
Debugging OIDC Tokens
To inspect OIDC token claims from your workflow, use GitHub’s actions-oidc-debugger tool. This tool helps you verify that the token claims match your machine identity configuration.For more detailed OIDC configuration options and troubleshooting, see OIDC Auth for GitHub Actions.
Alternative Approaches
GitHub Secret Syncs
If you prefer to push secrets from Infisical to GitHub (one-way sync), use GitHub Secret Syncs. This approach syncs secrets to GitHub at the organization-level, repository-level, or repository environment-level, making them available as GitHub Secrets.Secret Syncs push secrets to GitHub, while this guide shows how to fetch secrets from Infisical at runtime. Choose the approach that best fits your security and operational requirements.
Related Documentation
- OIDC Auth for GitHub Actions - Detailed OIDC configuration guide
- Machine Identities Overview - Understanding machine identities
- GitHub Secret Syncs - Syncing secrets to GitHub
- Infisical Secrets Action - Official GitHub Action repository