{"record":{"id":"b7bb6b45aeb3694e","repo":"denoland/deno","slug":"github-sha-environment-variable-is-not-set","errorCode":null,"errorMessage":"GITHUB_SHA environment variable is not set","messagePattern":"GITHUB_SHA environment variable is not set","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/publish/provenance.rs","lineNumber":185,"sourceCode":"    let rel_ref = std::env::var(\"GITHUB_WORKFLOW_REF\")\n      .unwrap_or_default()\n      .replace(&format!(\"{}/\", &repo), \"\");\n\n    let (workflow_path, workflow_ref) = if let Some(delimn) = rel_ref.find('@')\n    {\n      let (path, ref_) = rel_ref.split_at(delimn);\n      (path, &ref_[1..])\n    } else {\n      (rel_ref.as_str(), \"\")\n    };\n\n    let server_url = std::env::var(\"GITHUB_SERVER_URL\").map_err(|_| {\n      anyhow!(\"GITHUB_SERVER_URL environment variable is not set\")\n    })?;\n    let github_ref = std::env::var(\"GITHUB_REF\")\n      .map_err(|_| anyhow!(\"GITHUB_REF environment variable is not set\"))?;\n    let github_sha = std::env::var(\"GITHUB_SHA\")\n      .map_err(|_| anyhow!(\"GITHUB_SHA environment variable is not set\"))?;\n    let runner_env = std::env::var(\"RUNNER_ENVIRONMENT\").map_err(|_| {\n      anyhow!(\"RUNNER_ENVIRONMENT environment variable is not set\")\n    })?;\n    let run_id = std::env::var(\"GITHUB_RUN_ID\")\n      .map_err(|_| anyhow!(\"GITHUB_RUN_ID environment variable is not set\"))?;\n    let run_attempt = std::env::var(\"GITHUB_RUN_ATTEMPT\").map_err(|_| {\n      anyhow!(\"GITHUB_RUN_ATTEMPT environment variable is not set\")\n    })?;\n\n    Ok(Self {\n      build_definition: BuildDefinition {\n        build_type: GITHUB_BUILD_TYPE,\n        external_parameters: ExternalParameters {\n          workflow: GhaWorkflow {\n            ref_: workflow_ref.to_string(),\n            repository: format!(\"{}/{}\", server_url, &repo),\n            path: workflow_path.to_string(),\n          },","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/publish/provenance.rs#L167-L203","documentation":"Provenance predicate construction reads `GITHUB_SHA` (the commit being built) and throws this message when it is unset. It is one of several sequential required-variable reads; the first missing one aborts. On real runners it is always present, so this signals a stripped or simulated Actions environment.","triggerScenarios":"`deno publish --provenance` where earlier GITHUB_* variables survived into the process but GITHUB_SHA was filtered out — selective env forwarding or a custom runner setup.","commonSituations":"Containers or subprocess wrappers forwarding a hand-written subset of runner variables; CI systems emulating GitHub Actions env names.","solutions":["Forward GITHUB_SHA (and the rest of the GITHUB_*/RUNNER_* set) into the publish step","Run the publish step natively on the GitHub Actions runner","Drop `--provenance` outside GitHub Actions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if [ -z \"$GITHUB_SHA\" ]; then\n  echo \"GITHUB_SHA unset — publish --provenance needs the full Actions env\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include GITHUB_SHA in any forwarded env for containerized publish steps","Avoid wrappers that sanitize or whitelist environment variables","Preflight-check all required variables in one loop before invoking deno publish"],"tags":["publish","provenance","github-actions","environment","sigstore"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}