When setting up a GitHub action, my goal was to run a .sh script on my Ubuntu server. The script worked fine when triggering it manually with
bash myscript.sh
However, when running it with a GitHub action script like this:
on: push: branches: - main jobs: update_ssh_linode: name: Telling server to update runs-on: ubuntu-latest steps: - name: executing remote ssh commands using password uses: appleboy/ssh-action@master with: host: ${{ secrets.SERVER_HOST }} username: ${{ secrets.SERVER_USERNAME }} password: ${{ secrets.SERVER_PASSWORD }} port: ${{ secrets.PORT }} script: bash myscript.sh
I would get these errors in GitHub:
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 }
I wondered how that would be possible, since the server used Node.js v18.12.1. The solution that took me too long to find was to add these lines to the top of my .sh script, to make sure the script would execute its commands by using Node version 18.12.1:
source ~/.nvm/nvm.sh nvm use 18.12.1
The first line is necessary to use NVM in this script.