{"record":{"id":"025c61d40ea92033","repo":"denoland/deno","slug":"github-ref-environment-variable-is-not-set","errorCode":null,"errorMessage":"GITHUB_REF environment variable is not set","messagePattern":"GITHUB_REF environment variable is not set","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"cli/tools/publish/provenance.rs","lineNumber":183,"sourceCode":"      anyhow!(\"GITHUB_REPOSITORY environment variable is not set\")\n    })?;\n    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),","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/cli/tools/publish/provenance.rs#L165-L201","documentation":"Provenance predicate construction reads `GITHUB_REF` (the branch/tag ref being built) after GITHUB_SERVER_URL and throws this message when it is unset. All of these variables are stock on GitHub Actions runners; a missing one means the publish process is not seeing the full Actions environment.","triggerScenarios":"`deno publish --provenance` in an environment where GITHUB_REPOSITORY and GITHUB_SERVER_URL exist but GITHUB_REF does not — partial env forwarding into a container, or a wrapper that clears specific variables.","commonSituations":"Dockerized CI steps with selective env passthrough; minimal repro environments built by copying only a few runner variables.","solutions":["Forward the complete Actions environment into the publish process (GITHUB_REF included)","Run publish directly on the runner instead of through an env-sanitizing wrapper","Drop `--provenance` when publishing outside GitHub Actions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if [ -z \"$GITHUB_REF\" ]; then\n  echo \"GITHUB_REF unset — publish --provenance needs the full Actions env\" >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not hand-pick runner variables to forward; pass the whole environment","Keep provenance publishes on unmodified GitHub-hosted runners","Test the publish job on a real workflow run, not a local simulation"],"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"}