Merge pull request #7 from danmooozi/develop-commit #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up SSH key | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
- name: Scan for SSH keys | |
run: ssh-keyscan -v -t rsa ${{ secrets.SERVER_IP_ADDRESS }} >> ~/.ssh/known_hosts | |
- name: Deploy to server | |
run: | | |
ssh -v -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SERVER_IP_ADDRESS }} << 'ENDSSH' | |
sudo su | |
cd /home/ubuntu/pi-don | |
git checkout main | |
git pull origin main | |
npm install --production | |
pm2 restart be | |
ENDSSH | |