Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working-directory is being ignored #74

Open
Zerotask opened this issue Aug 30, 2023 · 9 comments
Open

working-directory is being ignored #74

Zerotask opened this issue Aug 30, 2023 · 9 comments

Comments

@Zerotask
Copy link

Zerotask commented Aug 30, 2023

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"

@ashiishme
Copy link

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

@Zerotask
Copy link
Author

Zerotask commented Sep 3, 2023

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.

@ashiishme
Copy link

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.

@ashiishme
Copy link

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.

@arvinsim
Copy link

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

@ijesneo611
Copy link

ijesneo611 commented Dec 23, 2023

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.

@NeoSahadeo
Copy link

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

@shaqdeff
Copy link

shaqdeff commented Mar 18, 2024

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!

Balthius pushed a commit to Balthius/Personal_Website that referenced this issue Mar 25, 2024
Battlesquid added a commit to Battlesquid/qnaplus that referenced this issue Mar 28, 2024
@oyal
Copy link

oyal commented May 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants