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

Cannot build Astro site with Node 20, "actions/checkout@v4" and "withastro/action@v2" #45

Open
basher opened this issue Feb 20, 2024 · 7 comments

Comments

@basher
Copy link

basher commented Feb 20, 2024

I bumped my Astro website Node version to 20 earlier today, but discovered I could no longer build and deploy via Github pages.

There's a related Node 20 bug, which is now closed.
And the related PR has been merged.

So... I have just modified my Github pages workflow YML with latest versions:
https://github.com/basher/basher-website/blob/master/.github/workflows/static.yml

But... I'm still getting build errors. The error doesn't provide me with any useful info:
https://github.com/basher/basher-website/actions/runs/7974519592/job/21770594265#step:3:41

Any ideas??? 🤔

@basher
Copy link
Author

basher commented Feb 20, 2024

I just tried renaming my npm-shrinkwrap.json to package-lock.json and got the same error, so it doesn't appear to be an issue with not being able to find an appropriate lock file.

@basher
Copy link
Author

basher commented Feb 20, 2024

I've managed to get node 18 working again by explicitly adding a node step:
https://github.com/basher/basher-website/blob/master/.github/workflows/static.yml#L24

I also reverted the other steps back to their original values.

@ARipeAppleByYoursTruly
Copy link

Your workflow file is currently using actions that are not at the latest versions, I think that might be the cause

Can you try bumping versions, comment out your Setup Node step, and see if that solves your problem?

Here are the version bumps you can try:

@basher
Copy link
Author

basher commented Apr 2, 2024

This still fails.

The setup node step allows me to build correctly for the time being.

Capture

@ARipeAppleByYoursTruly
Copy link

I think your lock file has to be package-lock.json to work, because I don't see npm-shrinkwrap.json in the conditions used in withastro/action's input validation

Would be nice if withastro/action provided a lock-file input as a fallback to unhandled lock file names

dgilleland added a commit to dgilleland/dgilleland.github.io that referenced this issue May 2, 2024
@muryoh
Copy link

muryoh commented Jul 23, 2024

fyi, was having the same problem on my end with

      - uses: withastro/action@v2
        with:
          path: ./packages/www
          package-manager: pnpm

Specifying package-manager: pnpm@latest it started to work...
I'm not fond of debugging github actions and the script seems like it should have handled it from what I can tell, so I didn't investigate further :)

@corporateuser
Copy link
Contributor

fyi, was having the same problem on my end with

      - uses: withastro/action@v2
        with:
          path: ./packages/www
          package-manager: pnpm

Specifying package-manager: pnpm@latest it started to work... I'm not fond of debugging github actions and the script seems like it should have handled it from what I can tell, so I didn't investigate further :)

You're right!
the problem is:
Actions start all shells with command shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}, where -o pipefail makes the whole pipe command return non-zero exit code if any of commands in the queue return non-zero exit code.
grep is having exit code 1 if searched expression was not found. You may test it yourself with:

pipefail is on:

set -o pipefail
INPUT_PM=pnpm
echo "$INPUT_PM" | grep -o '@.*' | sed 's/^@//'
echo $?

this will show 1, which means command has failed.

pipefail is off:

set +o pipefail
INPUT_PM=pnpm
echo "$INPUT_PM" | grep -o '@.*' | sed 's/^@//'
echo $?

this will show 0, which means command has not failed.

So to resolve the issue we have 2 possibilities:

  1. Change line to VERSION=$(echo "$INPUT_PM" | grep -o '@.*' || true | sed 's/^@//') - this is the preferred solution
  2. Just before line add set +o pipefail and set -o pipefail after this line

I've created a PR for the solution number 1

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

4 participants