【问题标题】:How to ignore node_modules in GitHub action function "hashFiles"?如何忽略 GitHub 操作函数“hashFiles”中的 node_modules?
【发布时间】:2021-08-17 12:26:36
【问题描述】:

我正在使用 cache GitHub 操作,并且正在使用内置的 hashFiles 函数生成缓存键:

key: ${{ runner.os }}-${{ hashFiles('./packages/protocol/{,!(node_modules)}**/*') }}-coverage-lcov

但是,上面的命令不起作用。我在 GitHub Actions 日志中看到的是这样的:

使用密钥保存的缓存:Linux--coverage-lcov

没有生成哈希,大概是因为 glob 不正确。如何正确忽略提供给hashFiles 函数的路径中的node_modules 文件夹?

【问题讨论】:

    标签: github-actions glob


    【解决方案1】:

    您的路径需要在单独的参数中,如the hashFiles docs page you linked上给出的示例所示:

    hashFiles('**/package-lock.json', '**/Gemfile.lock')
    

    此外,您似乎在 { 结束之后以及 node_modules 之前缺少一些 *,具体取决于您的目录设置。

    【讨论】:

    • 这也适用于负路径吗? IE。 !**/node_modules?
    • 有一个 Filter syntax cheat sheet from GitHub 包括 ! 所以,是的。您需要将它应该否定的术语封装在括号中
    猜你喜欢
    • 2019-04-19
    • 2016-10-15
    • 2021-05-14
    • 2023-02-07
    • 1970-01-01
    • 1970-01-01
    • 2016-07-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多