This repository has been archived by the owner on Jan 18, 2025. It is now read-only.
cari sendiri #20
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: Auto Deploy | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/[email protected] | |
with: | |
node-version: '21' | |
- name: Setup pnpm | |
uses: pnpm/[email protected] | |
with: | |
version: 'latest' | |
run_install: true | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build the project | |
run: pnpm run build | |
- name: Setup SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Deploy to VPS | |
run: | | |
rsync -avz --delete-after --progress \ | |
--exclude 'node_modules' \ | |
--exclude '.git' \ | |
-e "ssh -o StrictHostKeyChecking=no" \ | |
./ root@${{ secrets.VPS_IP }}:${{ secrets.VPS_PATH }} | |
- name: Restart Application | |
run: | | |
ssh -o StrictHostKeyChecking=no root@${{ secrets.VPS_IP }} << 'EOF' | |
cd /root/asepharyana.my.id | |
/root/.nvm/versions/node/v20.17.0/bin/pm2 restart web || /root/.nvm/versions/node/v20.17.0/bin/pm2 start npm --name "web" -- start | |
EOF | |