update action to delete any removed files #4
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 | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
production: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout 🛎 | |
uses: actions/checkout@master | |
- name: Install dependencies 👨🏻💻 | |
run: npm i | |
- name: Build for production 🏗️ | |
run: npm run build | |
- name: Setup SSH | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.SSH_PRIV_KEY }}" > ~/.ssh/id_rsa | |
echo "${{ secrets.SSH_PUB_KEY }}" > ~/.ssh/id_rsa.pub | |
chmod 600 ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa.pub | |
ssh-keyscan -H ${{ secrets.SSH_IP }} >> ~/.ssh/known_hosts | |
- name: Copy builds to server | |
run: | | |
rsync -vrm --delete dist package.json package-lock.json ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }}:/var/www/test-api.gomint.me/ | |
- name: Install dependencies on server and reload pm2 | |
run: | | |
ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_IP }} << 'EOF' | |
cd /var/www/test-api.gomint.me/ | |
npm ci | |
pm2 reload 0 | |
EOF |