Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude files for creating artifact files on Github Actions

I'm new to Github Actions. I have a project using 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. 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

like image 566
shinyatk Avatar asked Jun 17 '26 07:06

shinyatk


2 Answers

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

like image 142
Willian Souza Avatar answered Jun 21 '26 05:06

Willian Souza


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.

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: .
like image 22
peterevans Avatar answered Jun 21 '26 07:06

peterevans



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!