{
  "id": "policy/github-actions-self-hosted-runner-token-expired",
  "signature": "Error: The self-hosted runner registration token has expired. Please generate a new token and re-register the runner.",
  "signature_zh": "错误：自托管运行器注册令牌已过期。请生成新令牌并重新注册运行器。",
  "regex": "The self-hosted runner registration token has expired\\. Please generate a new token and re-register the runner\\.",
  "domain": "policy",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "GitHub self-hosted runner registration tokens have a configurable expiration (default 1 hour) and if the runner registration process is delayed or the token is stored and reused after expiration, registration fails.",
  "root_cause_type": "generic",
  "root_cause_zh": "GitHub 自托管运行器注册令牌具有可配置的过期时间（默认 1 小时），如果运行器注册过程延迟或令牌在过期后被存储并重用，注册将失败。",
  "versions": [
    {
      "version": "GitHub Actions Runner v2.311.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "GitHub Actions Runner v2.312.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "GitHub Actions Runner v2.313.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Restarting the runner service",
      "why_fails": "Restarting the runner service does not refresh the expired token; the token is only valid for initial registration, not for ongoing operations.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Editing .runner file to extend token expiration",
      "why_fails": "Modifying the .runner file to extend the expiration date manually will not work because the token is validated server-side by GitHub.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Deleting and re-adding with same token",
      "why_fails": "Deleting the runner from GitHub and re-adding it with the same expired token will still fail; a new token must be generated.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Generate a new registration token from GitHub repository settings and re-register the runner.\nExample:\n  # On GitHub: Settings > Actions > Runners > New self-hosted runner > Copy token\n  # On runner machine:\n  ./config.sh remove --token OLD_TOKEN\n  ./config.sh --url https://github.com/owner/repo --token NEW_TOKEN\n  ./run.sh",
      "success_rate": 0.95,
      "how": "Generate a new registration token from GitHub repository settings and re-register the runner.\nExample:\n  # On GitHub: Settings > Actions > Runners > New self-hosted runner > Copy token\n  # On runner machine:\n  ./config.sh remove --token OLD_TOKEN\n  ./config.sh --url https://github.com/owner/repo --token NEW_TOKEN\n  ./run.sh",
      "condition": "",
      "sources": []
    },
    {
      "action": "Automate token generation using GitHub API in a script to avoid manual steps.\nExample:\n  # Get token using GitHub API\n  TOKEN=$(curl -s -X POST -H \"Authorization: token $GITHUB_PAT\" \\\n    https://api.github.com/repos/owner/repo/actions/runners/registration-token | jq -r '.token')\n  ./config.sh --url https://github.com/owner/repo --token $TOKEN",
      "success_rate": 0.9,
      "how": "Automate token generation using GitHub API in a script to avoid manual steps.\nExample:\n  # Get token using GitHub API\n  TOKEN=$(curl -s -X POST -H \"Authorization: token $GITHUB_PAT\" \\\n    https://api.github.com/repos/owner/repo/actions/runners/registration-token | jq -r '.token')\n  ./config.sh --url https://github.com/owner/repo --token $TOKEN",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a service like Terraform or Ansible to manage runner registration, ensuring tokens are generated fresh each time.\nExample (Terraform):\n  resource \"github_actions_runner_registration_token\" \"this\" {\n    repository = \"owner/repo\"\n  }\n  # Then use the token in a provisioner",
      "success_rate": 0.85,
      "how": "Use a service like Terraform or Ansible to manage runner registration, ensuring tokens are generated fresh each time.\nExample (Terraform):\n  resource \"github_actions_runner_registration_token\" \"this\" {\n    repository = \"owner/repo\"\n  }\n  # Then use the token in a provisioner",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "从 GitHub 仓库设置生成新的注册令牌并重新注册运行器。\n示例：\n  # 在 GitHub 上：设置 > 操作 > 运行器 > 新建自托管运行器 > 复制令牌\n  # 在运行器机器上：\n  ./config.sh remove --token OLD_TOKEN\n  ./config.sh --url https://github.com/owner/repo --token NEW_TOKEN\n  ./run.sh",
    "使用 GitHub API 在脚本中自动化令牌生成，避免手动步骤。\n示例：\n  # 使用 GitHub API 获取令牌\n  TOKEN=$(curl -s -X POST -H \"Authorization: token $GITHUB_PAT\" \\\n    https://api.github.com/repos/owner/repo/actions/runners/registration-token | jq -r '.token')\n  ./config.sh --url https://github.com/owner/repo --token $TOKEN",
    "使用 Terraform 或 Ansible 等基础设施即代码工具管理运行器注册，确保每次生成全新的令牌。\n示例（Terraform）：\n  resource \"github_actions_runner_registration_token\" \"this\" {\n    repository = \"owner/repo\"\n  }\n  # 然后在 provisioner 中使用令牌"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}