Skip to content

Merge pull request #68 from valueGa/develop #2

Merge pull request #68 from valueGa/develop

Merge pull request #68 from valueGa/develop #2

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: |
npm install
npm ci
# Build step removed since there is no build script
- name: Copy files via SSH
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
port: 22
source: "."
target: "/home/ubuntu/valueGa-FE"
- name: Execute remote commands via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_KEY }}
port: 22
script: |
sudo apt update
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Navigate to the application directory
cd /home/ubuntu/valueGa-FE
# Install project dependencies
npm install
# Restart or start the application with pm2
npm run build
sudo rm -rf /var/www/dist
sudo mv dist /var/www