nuxt generate
failed, but github workflow
didn't know about it and still forced the deployment, causing the website to display errors.
My old code:
run: npm install && npm run generate
If an error occurs, the GitHub workflow will theoretically be interrupted. The problem lies in npm run generate
. If a single page of nuxt generate
reports an error, an error message will be displayed, but no error signal will be output, so the GitHub workflow does not know.
The code I modified adds two checks. If there is an error signal, exit. If the output contains the key string Composer.onError
, exit.
run: |
output=$(npm install && npm run generate)
echo "$output"
if [ $? -ne 0 ]; then
echo "Installation or build failed, command execution returned a non-zero status code."
exit 1
fi
if echo "$output" | grep -i "at Composer.onError"; then
echo "Installation or build failed because output contains 'at Composer.onError'."
exit 1
fi