Skip to content

chore:

chore: #7

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
setup:
runs-on: ubuntu-latest
steps:
# Step 1: Install NVM and Node.js on the remote server
- name: Install NVM and Node.js
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
# Install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # Load nvm bash_completion
# Install Node.js using NVM
nvm install --lts
nvm use --lts
node -v # Check the installed version of Node.js
npm -v # Check the installed version of npm
# Step 2: Clone the repository via SSH and navigate to the correct directory
- name: Deploy & Clone Repository
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
if [ ! -d "/root/GOPAT" ]; then
git clone https://wildonion:${{ secrets.ACCESS_TOKEN }}@github.com/wildonion/SomeUiRepo.git
fi
cd GOPAT
git stash
git pull origin main
pwd
# Step 3: Run npm install to set up the dependencies
- name: Install NPM Dependencies
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm
nvm use --lts
cd /root/GOPAT
npm install # Install npm dependencies
build:
runs-on: ubuntu-latest
needs: setup
steps:
# Step 4: Run npm build after dependencies are installed
- name: Build Project
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: 22
script: |
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm
nvm use --lts
cd /root/GOPAT
npm run build