Skip to content

Commit

Permalink
refactor: add build check before making changes to the actual prod vps
Browse files Browse the repository at this point in the history
  • Loading branch information
NotSugat committed Sep 28, 2024
1 parent eaa7a16 commit 81c8b21
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions .github/workflows/deploy-to-vps.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Build & deploy in VPS

name: test build

on:
push:
branches:
Expand All @@ -10,7 +12,29 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Deploy using ssh
- name: Checkout code
uses: actions/checkout@v2

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: "20"

- name: Install dependencies
run: yarn install

- name: Build
run: yarn run build

deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Deploy using SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
Expand All @@ -19,12 +43,7 @@ jobs:
port: 22
script: |
cd ~/website
git pull origin main
yarn install
yarn build
if [ $? -ne 0 ]; then
echo "Build failed"
exit 1
fi
pm2 restart .
2 changes: 1 addition & 1 deletion
git pull origin main || { echo "Failed to pull latest changes from Git repository"; exit 1; }
yarn install || { echo "Failed to install dependencies"; exit 1; }
yarn run build || { echo "Build failed"; exit 1; }
pm2 restart kuosc || { echo "Failed to restart PM2"; exit 1; }

0 comments on commit 81c8b21

Please sign in to comment.