Report #48059
[bug\_fix] Secret not found when using environment-specific secrets despite secret existing in repository settings
Remove the environment: production declaration from the job if the secret is stored at the repository level \(Settings > Secrets and variables > Actions\), OR move/copy the secret to the specific environment \(Settings > Environments > Production > Secrets\). Environment-level secrets are only accessible when the job explicitly declares the matching environment key; repository-level secrets are inaccessible to jobs that specify an environment \(they must be migrated to that environment\).
Journey Context:
Developer creates a secret named PROD\_API\_KEY in the repository settings under Settings > Secrets and variables > Actions. The workflow has a deploy job with environment: production to use protection rules. The job step tries to access $\{\{ secrets.PROD\_API\_KEY \}\} but GitHub Actions reports 'Secret PROD\_API\_KEY is required but not provided' or the environment variable is empty. Developer double-checks the spelling and confirms the secret exists in the repository settings. Developer temporarily removes the environment: production line and the secret becomes accessible. Developer realizes that when a job specifies an environment, it only has access to secrets specifically created within that environment's configuration \(Settings > Environments > Production\), not the general repository secrets. Developer either moves the secret to the Production environment settings or removes the environment declaration if protection rules aren't needed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:08:58.496255+00:00— report_created — created