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

update.sh works properly when triggered manual, but not when triggered via this GitHub shh-action #202

Closed
belowsurface3000 opened this issue Dec 11, 2022 · 6 comments

Comments

@belowsurface3000
Copy link

It all worked fine for a simple repo with a Node.js server that provides an index.html. However in my first complex project, after installing the Node.js NPM's, the script navigates into the client folder and tries to install the NPM's here aswell and get errors of this kind:

err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: '@npmcli/fs@3.1.0',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }
err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: '@npmcli/git@4.0.3',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }
err: npm WARN EBADENGINE Unsupported engine {
err: npm WARN EBADENGINE   package: 'which@3.0.0',
err: npm WARN EBADENGINE   required: { node: '^14.17.0 || ^16.13.0 || >=18.0.0' },
err: npm WARN EBADENGINE   current: { node: 'v12.***.9', npm: '8.5.1' }
err: npm WARN EBADENGINE }

the weird thing: when i log into the ubuntu server with the same credentials by hand and run the .sh file with bash, it works perfectly fine. the installed Node version is v18.12.1, npm is 8.19.2. So I really dont understand why the error state that node version 12 is used. Ubuntu is Version 22.04.1 LTS.

any ideas?

@martianmaikel
Copy link

I have a very similar problem.
I get this Error:

err: ERROR: npm v9.2.0 is known not to run on Node.js v10.19.0. You'll need to upgrade
err: to a newer Node.js version in order to use this version of npm. This version of
err: npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You
err: can find the latest version at [https://nodejs.org/.](https://nodejs.org/)

but my Version on my vServer is v16.2.0 and npm v8.19.2. Manually it builds and installs without errors.
Ubuntu 20.04.5 LTS

@vygandas
Copy link

vygandas commented Jan 3, 2023

Same problem here. I am logging into EC2 with the username ubuntu. SSH key is generated also for the same user. ssh-action manages to login, but this what I get:

======CMD======
source /home/***/.profile
cd /home/***
sh deploy.sh

======END======
err: deploy.sh: 2: source: not found
out: Fetching origin
err: From github.com:***/***
err:    5cfd1da..d324c64  main       -> origin/main
out: HEAD is now at d324c64 added deploy.yml
err: deploy.sh: 6: yarn: not found
err: deploy.sh: 7: yarn: not found
err: deploy.sh: 9: pm2: not found
20[23](https://github.com/***/***/actions/runs/3830070786/jobs/6517485835#step:3:24)/01/03 13:57:59 Process exited with status 1[27](https://github.com/***/***/actions/runs/3830070786/jobs/6517485835#step:3:28)

And the deploy.sh is this:

#!/bin/sh
source /home/ubuntu/.profile
cd /home/ubuntu/***
git fetch --all
git reset --hard origin/main
yarn
yarn build
cd /home/ubuntu
pm2 restart ecosystem.config.js --env production

Tried master and locked version appleboy/ssh-action@v0.1.6. Tried various other things, like adding install scripts in the sh and so on... No more ideas so I'm writing here.

Script works when I login as ubuntu via terminal and run sh deploy.sh. 🤔

@blackshady
Copy link

I am having the same issue. I can't run a script after gaining ssh access via shh-action. But everything works fine when I access my server manually.

err: bash: line 8: yarn: command not found
err: bash: line 9: yarn: command not found
err: bash: line 10: yarn: command not found
out: Running PM2
err: bash: line 12: pm2: command not found
err: bash: line 13: pm2: command not found
2023/01/20 19:23:42 Process exited with status 127

@vygandas were you able to get it to work?

@sinhpn92
Copy link

Did anyone fix this issue?

@appleboy
Copy link
Owner

Please refer to #70

@belowsurface3000
Copy link
Author

belowsurface3000 commented Apr 11, 2023

MY SOLUTION: obviously the Node.js version was wrong. But why would that happen, if we execute the same script? The solution that worked for me, was to make sure the correct Node version is used in the .sh script. This can be done by adding these two lines at the top of the script (add the Node version you want):

source ~/.nvm/nvm.sh
nvm use 18.12.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

6 participants