简体   繁体   English

排除用于在 Github 操作上创建工件文件的文件

[英]Exclude files for creating artifact files on Github Actions

I'm new to Github Actions.我是 Github 操作的新手。 I have a project using node_modules.我有一个使用 node_modules 的项目。 I would like to create artifact files without including node_modules on Github Actions since with node_modules it takes a while to create and download because of the file size.我想在 Github Actions 上创建不包含 node_modules 的工件文件,因为使用 node_modules 由于文件大小,创建和下载需要一段时间。 Is there a way to do this?有没有办法做到这一点?

This one seems a bit related with this but could not figure it out how.这似乎与此有关,但无法弄清楚如何。 https://github.com/actions/upload-artifact/issues/44 https://github.com/actions/upload-artifact/issues/44

I don't think it's possible to exclude paths yet because the action only accepts a single path.我认为还不能排除路径,因为该操作只接受一条路径。 According to the issue you linked, they are looking to add multiple path support in the future.根据您链接的问题,他们希望将来添加多路径支持。

The workaround I've used is just to delete the node_modules directory before creating the artifact.我使用的解决方法只是在创建工件之前删除node_modules目录。

For example:例如:

      - run: |
          npm ci
          npm run build
          npm run test
          npm run package
          rm -rf node_modules

      - uses: actions/upload-artifact@v2
        with:
          name: my-artifact
          path: .

You can use ignore by pattern您可以按模式使用忽略

  - uses: actions/upload-artifact@v2
    with:
      name: my-artifact
      path: |
         .
         !./node_modules

Source: https://github.com/actions/upload-artifact#upload-using-multiple-paths-and-exclusions来源: https://github.com/actions/upload-artifact#upload-using-multiple-paths-and-exclusions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM