githubnext.jsgithub-actionscicd

GitHub actions does not upload .bin folder to artifacts


I am using github workflow to install dependencies and bulid a nextjs application. However, when I upload my artifacts the .bin folder from node_modules is missing. .bin directory exists after installing dependencies on the self-hosted runner.

My workflow file:

name: build-application

on:
  push:
    branches:
      - '*'
  pull_request:
    branches:
      - '*'

jobs:
  build:

    runs-on: self-hosted

    strategy:
      matrix:
        node-version: [22.x]

    steps:
    - uses: actions/checkout@v4
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v4
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - name: 📥 Install dependecies; 🏗️ Build code
      run: |
        npm ci
        npm run build --if-present
        #npm test
        echo "🎉  The build was successfully completed!"
    - name: List node_modules contents
      run: | 
        ls -al node_modules | grep .bin
        pwd
    - name: Upload Build Artifacts
      uses: actions/upload-artifact@v4
      with:
        name: nextjs-build
        path: |
          .next
          public
          package.json
          next.config.js
          node_modules

Github actions logs:

Run ls -al node_modules | grep .bin
drwxr-xr-x   2 ubuntu ubuntu   4096 Jan 24 20:18 .bin
drwxr-xr-x   2 ubuntu ubuntu   4096 Jan 24 20:17 binary-extensions
drwxr-xr-x   4 ubuntu ubuntu   4096 Jan 24 20:17 call-bind
drwxr-xr-x   3 ubuntu ubuntu   4096 Jan 24 20:17 combined-stream
drwxr-xr-x   4 ubuntu ubuntu   4096 Jan 24 20:17 function-bind
drwxr-xr-x   2 ubuntu ubuntu   4096 Jan 24 20:17 is-binary-path
With the provided path, there will be 17260 files uploaded
Artifact name is valid!
Root directory input is valid!
Beginning upload of artifact content to blob storage
Uploaded bytes 8388608
Uploaded bytes 16777216
Uploaded bytes 25165824
Uploaded bytes 33554432
Uploaded bytes 41943040
Uploaded bytes 50331648
Uploaded bytes 58720256
Uploaded bytes 67108864
Uploaded bytes 75497472
Uploaded bytes 83886080
Uploaded bytes 92274688
Uploaded bytes 100663296
Uploaded bytes 109051904
Uploaded bytes 117440512
Uploaded bytes 125829120
Uploaded bytes 134217728
Uploaded bytes 142606336
Uploaded bytes 150994944
Uploaded bytes 159383552
Uploaded bytes 167772160
Uploaded bytes 169846319
Finished uploading artifact content to blob storage!

When I download the zip file of the artifacts there is no .bin folder.

And when I try to just upload node_modules/.bin folder to artifacts it throws an error as if it could not find a path to it:

Warning: No files were found with the provided path:
node_modules/.bin. No artifacts will be uploaded.

I need that folder to run the server after the CD.

Update. Looks like the .bin folder only contains the links to the actual binaries. Is that the possible reason why I cannot get that directory uploaded to the artifacts?

s -al node_modules/.bin/
total 16
drwxr-xr-x   2 ubuntu ubuntu  4096 Jan 24 20:30 .
drwxr-xr-x 338 ubuntu ubuntu 12288 Jan 24 20:30 ..
lrwxrwxrwx   1 ubuntu ubuntu    18 Jan 24 20:30 acorn -> ../acorn/bin/acorn
lrwxrwxrwx   1 ubuntu ubuntu    32 Jan 24 20:30 autoprefixer -> ../autoprefixer/bin/autoprefixer
lrwxrwxrwx   1 ubuntu ubuntu    22 Jan 24 20:30 browserslist -> ../browserslist/cli.js
lrwxrwxrwx   1 ubuntu ubuntu    20 Jan 24 20:30 cssesc -> ../cssesc/bin/cssesc
lrwxrwxrwx   1 ubuntu ubuntu    23 Jan 24 20:30 eslint -> ../eslint/bin/eslint.js
lrwxrwxrwx   1 ubuntu ubuntu    19 Jan 24 20:30 jiti -> ../jiti/bin/jiti.js
lrwxrwxrwx   1 ubuntu ubuntu    19 Jan 24 20:30 json5 -> ../json5/lib/cli.js
lrwxrwxrwx   1 ubuntu ubuntu    25 Jan 24 20:30 js-yaml -> ../js-yaml/bin/js-yaml.js
lrwxrwxrwx   1 ubuntu ubuntu    22 Jan 24 20:30 loose-envify -> ../loose-envify/cli.js
lrwxrwxrwx   1 ubuntu ubuntu    24 Jan 24 20:30 nanoid -> ../nanoid/bin/nanoid.cjs
lrwxrwxrwx   1 ubuntu ubuntu    21 Jan 24 20:30 next -> ../next/dist/bin/next
lrwxrwxrwx   1 ubuntu ubuntu    23 Jan 24 20:30 node-which -> ../which/bin/node-which
lrwxrwxrwx   1 ubuntu ubuntu    28 Jan 24 20:30 prettier -> ../prettier/bin/prettier.cjs
lrwxrwxrwx   1 ubuntu ubuntu    22 Jan 24 20:30 resolve -> ../resolve/bin/resolve
lrwxrwxrwx   1 ubuntu ubuntu    16 Jan 24 20:30 rimraf -> ../rimraf/bin.js
lrwxrwxrwx   1 ubuntu ubuntu    23 Jan 24 20:30 semver -> ../semver/bin/semver.js
lrwxrwxrwx   1 ubuntu ubuntu    22 Jan 24 20:30 sucrase -> ../sucrase/bin/sucrase
lrwxrwxrwx   1 ubuntu ubuntu    27 Jan 24 20:30 sucrase-node -> ../sucrase/bin/sucrase-node
lrwxrwxrwx   1 ubuntu ubuntu    25 Jan 24 20:30 tailwind -> ../tailwindcss/lib/cli.js
lrwxrwxrwx   1 ubuntu ubuntu    25 Jan 24 20:30 tailwindcss -> ../tailwindcss/lib/cli.js
lrwxrwxrwx   1 ubuntu ubuntu    21 Jan 24 20:30 tsc -> ../typescript/bin/tsc
lrwxrwxrwx   1 ubuntu ubuntu    26 Jan 24 20:30 tsserver -> ../typescript/bin/tsserver
lrwxrwxrwx   1 ubuntu ubuntu    32 Jan 24 20:30 update-browserslist-db -> ../update-browserslist-db/cli.js


Solution

  • Hidden ("dot") files are by default excluded. You have to include them explicitly with an option:

       - name: Upload Build Artifacts
          uses: actions/upload-artifact@v4
          with:
            name: nextjs-build
            include-hidden-files: true  # <-- This one!
            path: |
              .next
              public
              package.json
              next.config.js
              node_modules
    

    This was a breaking change in v4.4.0 of the action.