actions / upload-pages-artifact

A composite action for packaging and uploading an artifact that can be deployed to GitHub Pages.

Home Page:https://pages.github.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`working-directory` is being ignored

Zerotask opened this issue · comments

In my job, I have set a working-directory (docs/user) right at the start.

runs-on: ubuntu-latest
defaults:
  run:
    working-directory: ./docs/user

In this directory I run a build step which creates a dist directory (docs/user/dist).

If you try to run

- name: Upload artifact
  uses: actions/upload-pages-artifact@v2
  with:
    path: "dist"

you will get the error:

Run actions/upload-pages-artifact@v2
  with:
    path: dist
    name: github-pages
    retention-days: 1
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    GITHUB_PAGES: true
Run tar \
  tar \
    --dereference --hard-dereference \
    --directory "$INPUT_PATH" \
    -cvf "$RUNNER_TEMP/artifact.tar" \
    --exclude=.git \
    --exclude=.github \
    .
  shell: /usr/bin/sh -e {0}
  env:
    pythonLocation: /opt/hostedtoolcache/Python/3.11.4/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.11.4/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.11.4/x64/lib
    GITHUB_PAGES: true
    INPUT_PATH: dist
tar: dist: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Error: Process completed with exit code 2.

I'd assume that it considers my previously set working-directory, but I had to change it to path: "docs/user/dist"

Have you managed to fix it? I am experiencing same issue.

Have you managed to fix it? I am experiencing same issue.

Yes, as I wrote, you have to set the absolute path, not the relative path.

I have the absolute path defined for the uploading but it seems to fail with same error.

docs/out < this is the directory I am pointing to.

docs is where my application is located.

nvm, in my case it was a different issue but indeed the absolute path is the solution. The out directory was not generated in my case because of the missing property in my config file as per the new changes from NextJS but after fixing it, the absolute path fixed the upload issue. Thanks.

@ashiishme Seems that some tutorials do not reflect the new NextJS changes. Hence why we get this error.

Have you managed to fix it? I am experiencing same issue.

Ubuntu_9; system AI mine.GE babysitter with Christopher topper as an overview fewer and also the person who denied him Christmas gifts.

Artifact error exit code: 2 when build Nextjs

Moved a bunch of files around between projects and that broke the build process

Solution

Fixed NextJs build workflow by renaming the next.config.mjs to next.config.js and changing the export statement to use commonjs type.

Build Error in question

Artifact error exit code: 2 when build Nextjs

Moved a bunch of files around between projects and that broke the build process

Solution

Fixed NextJs build workflow by renaming the next.config.mjs to next.config.js and changing the export statement to use commonjs type.

Build Error in question

@NeoSahadeo Million thanks for this! I've been stressing for hours with this till I came across your answer! Bless you!

commented

Related to this: actions/configure-pages@v4. For Next.js 14, please use v5 version.

- name: Setup Pages
  uses: actions/configure-pages@v5
  with:
    static_site_generator: next

actions/configure-pages#137