I am trying to automate my next js deployment and write a deploy.sh script to run on the server using github actions. I tried running it manully on server using bash deploy.sh command and it works fine but when i run it through github actions it says: ‘err: .scripts/deploy.sh: line 14: npm: command not found’
This is my main.yaml file
name: main
on:
push:
branches: [“main”]
pull_request:
branches: [“main”]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v3
- name: Deploy to Server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.SSHKEY }}
script: "cd ~/gempad-Interface && bash .scripts/deploy.sh"
This is my deploy.sh file
#!/bin/bash
set -e
echo “Deployment started…”
expect <<EOF
spawn git pull origin main
expect “Enter passphrase for key ‘/***/.ssh/id_ed25519’:”
send “iamanasn”
expect eof
EOF
echo “New changes copied to server !”
echo “Installing Dependencies…”
pnpm install
echo “Creating Production Build…”
pnpm run build
echo “PM2 Reload”
pm2 reload gemlaunch-interface
echo “Deployment Finished!”
Muhammad Anas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.