github action部署失败问题

901 阅读2分钟

我以为可以一直用下去的action竟然给我一个红色的X

image.png

至此,已稳稳的运行了2-3年了,需要保养一下。

在使用 GitHub Actions 时,如果遇到 Missing download info for actions/cache@v2 错误,通常是因为 GitHub Actions 无法正确下载或访问 actions/cache 这个 Action。

以下是可能的原因和解决方法:

1. 网络问题

  • 原因:GitHub 的服务器可能暂时无法访问或下载 actions/cache
  • 解决方法
    • 等待一段时间后重试。
    • 检查 GitHub Status 页面,确认是否有服务中断。

2. 版本问题 get

我更换了版本就可以了。

  • 原因actions/cache@v2 可能已被弃用或更新。
  • 解决方法
    • 尝试使用最新版本,例如 actions/cache@v3
    • 修改工作流文件:
      - uses: actions/cache@v3
      

3. 缓存路径问题

  • 原因:缓存路径配置错误,导致无法正确下载缓存。
  • 解决方法
    • 检查 pathkey 配置是否正确。
    • 示例:
      - uses: actions/cache@v3
        with:
          path: |
            node_modules
            dist
          key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
      

4. 权限问题

  • 原因:GitHub Actions 没有足够的权限访问缓存。
  • 解决方法
    • 确保工作流文件中的 permissions 配置正确。
    • 示例:
      permissions:
        actions: write
        contents: read
      

5. 缓存过期

  • 原因:缓存可能已过期或被清理。
  • 解决方法
    • 重新生成缓存。
    • 检查 restore-keys 配置,确保有备用缓存可用。
    • 示例:
      - uses: actions/cache@v3
        with:
          path: node_modules
          key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-build-
      

6. 工作流文件语法错误

7. 更新 GitHub Actions Runner

  • 原因:使用的 GitHub Actions Runner 版本过旧,可能不支持某些功能。
  • 解决方法
    • 更新到最新版本的 GitHub Actions Runner。

总结

遇到 Missing download info for actions/cache@v2 错误时,可以按照以下步骤排查:

  1. 检查网络连接和 GitHub 服务状态。
  2. 更新 actions/cache 到最新版本(如 v3)。
  3. 检查缓存路径和权限配置。
  4. 确保工作流文件语法正确。