Skip to main content
This guide walks you through fetching secrets from Infisical inside a GitHub Actions workflow. The Infisical Secrets Action authenticates as a machine identity, fetches the secrets that identity is allowed to read, and injects them into your job as environment variables. The values exist only for the lifetime of the job, so you don’t have to copy secrets into GitHub Secrets or keep them in sync there.
To push secrets from Infisical into GitHub Secrets instead, use GitHub Secret Syncs. Secret Syncs write secrets to GitHub, while this guide fetches them from Infisical at runtime.

Prerequisites

Setup

Choose how your workflow should authenticate with Infisical:
If your workflow runs on a self-hosted runner in AWS, the action can also authenticate with AWS Auth by setting method: "aws-iam" and identity-id. The runner needs AWS credentials it can use and network access to the AWS STS endpoints.

Configure the action

Reference secrets in later steps

Fetched secrets are available as environment variables to every later step in the same job. Reference them with standard environment variable syntax:
The action registers each fetched value as a masked secret, so GitHub redacts it from logs. Masking is a safety net rather than a guarantee: transformed values, such as a secret that a tool base64-encodes or embeds in a URL, can still appear in output. Don’t print secrets.

Fetch from a specific folder

By default the action fetches secrets from the root of the environment. Set secret-path to read from a folder, and recursive to include its subfolders:

Write secrets to a file

If your application reads a .env file instead of environment variables, set export-type to file. The path is relative to the workspace, so check out the repository first:
Values written to a file aren’t masked in logs, and the file stays in the workspace for the rest of the job. Don’t commit it or upload it as a build artifact.

EU Cloud and self-hosted instances

The action targets Infisical Cloud US by default. Set domain to point it elsewhere:
If your instance uses a certificate from an internal certificate authority, commit the CA certificate to your repository and point the job at it:
If your instance sits behind a header-based firewall, pass the required headers with extra-headers, one Header-Name: value pair per line.

Action inputs

Pin the action to a specific release rather than a branch so your workflows stay reproducible. Check the releases page for the current version.

Troubleshooting

Work through these in order:
  1. Confirm the workflow sets permissions: id-token: write. Without it, GitHub never issues a token.
  2. Confirm the Subject on the machine identity matches the repository and context the workflow actually runs in. A workflow triggered on a pull request or a tag has a different subject than one on main.
  3. Confirm the Audiences value matches the audience in the token, which is the repository owner’s URL unless you set oidc-audience.
  4. Confirm the identity was added to the project, not just created in the organization.
  5. Confirm method and the matching credential inputs are set. Without method: "oidc", the action defaults to Universal Auth and fails on missing credentials.
GitHub.com repositories created after July 15, 2026 use immutable subject claims. The repository owner and name are suffixed with their permanent numeric IDs, so a subject configured with the previous format won’t match and Infisical returns a 403 error.For example, the subject changed from:
To:
Renaming or transferring a repository after that date also switches it to the immutable format. Existing repositories can opt in through GitHub’s OIDC settings or REST API. GitHub Enterprise Server is unaffected. See GitHub’s immutable subject claims announcement for details.Run gh api repos/<owner>/<repo>/actions/oidc/customization/sub and copy the sub_claim_prefix value into the machine identity’s Subject field. A glob pattern such as repo:octocat@*/orders-service@*:ref:refs/heads/main can serve as a temporary workaround during migration, but it can also match recycled owner and repository names with different IDs. Use the exact IDs whenever possible.
The action only injects what the identity can read from the path you requested. Check that:
  • project-slug matches the slug from Copy Project Slug, not the project name
  • env-slug matches the environment’s slug rather than its display name. Slugs are lowercase, typically dev, staging, and prod
  • secret-path points at the folder holding the secrets, with recursive: true if they live in subfolders
  • The identity’s project role grants read access to that environment and path
Run github/actions-oidc-debugger in the repository to print the token’s claims, then compare them against the subject, audience, and claims configured on your machine identity. This is the fastest way to resolve a subject mismatch.
Yes. Add the action once for each source. When two sources define the same key, the later step’s value wins, so order the steps accordingly. If you export to files, give each step a different file-output-path.

Next steps

OIDC Auth

Review the full set of OIDC configuration options for GitHub.

Machine Identities

Understand how identities authenticate and what they can access.

GitHub Secret Syncs

Push secrets from Infisical into GitHub Secrets instead.

Secrets Delivery

Compare delivery methods across CI/CD, Kubernetes, and applications.