Skip to content
Latchkey

GitHub Actions "Missing environment 'production'"

A job that names environment: production expects an environment defined in the repository. If it is misspelled or never created, the deploy cannot resolve its protection rules, secrets, or URL.

What this error means

The deploy job fails or the environment-scoped secrets are empty because the named environment does not match any configured environment.

github-actions
Error: Missing environment 'production'
The environment referenced in the job does not exist in this repository.

Common causes

Environment never created

No environment named production exists under Settings > Environments, so the reference has nothing to bind to.

Name mismatch or casing

The job uses a slightly different name (prod, Production) than the configured environment.

How to fix it

Create or correct the environment name

  1. Create the environment under Settings > Environments with the exact name used in the job.
  2. Or change the job to reference the existing environment name (names are case-sensitive in matching).
  3. Add protection rules and environment secrets there if the deploy needs them.
.github/workflows/deploy.yml
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: production
      url: ${{ steps.deploy.outputs.page_url }}

How to prevent it

  • Define every referenced environment in repository settings before merging the workflow.
  • Keep environment names consistent across workflows to avoid drift.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →