DEBUG.WIKI
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
晚安云;香港 CN2 ¥15/月
V.PS:让项目靠近用户,亚太、欧洲、北美 KVM VPS

解决 GitHub Actions 报错 Cache Service Url not found 缓存异常修复

排查 自建 runner (Self-hosted) 运行 actions/cache 报错 Cache Service Url not found,分析自建 Runner 缓存服务缺失解决方案。

问题现象

在自建 Self-hosted Runner 上运行包含 actions/cache@v3 的流程时报错:

Warning: An error occurred getting the cache: Cache Service Url not found, unable to restore cache.

触发根因

  1. 官方的 actions/cache 深度依赖 GitHub 托管云的私有内部缓存 API 服务;
  2. 企业私有部署的 Self-hosted Runner 默认无法访问或未挂接对应的 GitHub Actions 缓存代理服务。

解决步骤

改用基于本地文件系统的缓存 Action 替代

使用支持本地磁盘路径的开源缓存替代方案(如 actions-cache/local):

- name: Restore local cache
  uses: actions/cache@v3
  with:
    path: ~/.m2/repository
    key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
    enableCrossOsArchive: false

若自建企业服务,部署 actions-cache-server

在内部集群搭建兼容的后端缓存存储端点。

验证确认

重新运行工作流:

依赖库从本地高速存储秒级命中恢复,无任何警告与缺失报错。