Skip to content

Instantly share code, notes, and snippets.

@Vincenius
Last active November 7, 2023 06:12
Show Gist options
  • Save Vincenius/9364e7816386d12fa956996359f0523e to your computer and use it in GitHub Desktop.
Save Vincenius/9364e7816386d12fa956996359f0523e to your computer and use it in GitHub Desktop.
Github Action - Deploy to Linux using password
name: Deploy to Server
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: SSH into the server and run a command
run: |
sshpass -p ${{ secrets.SSH_PASSWORD }} ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@YOUR_IP << 'EOF'
echo "Connected!!!"
export PATH="$PATH:/root/.nvm/versions/node/YOUR_NODE_VERSION/bin"
cd ~/your/application
git pull
yarn
yarn build
pm2 restart your-application
echo "Deployment done!"
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment