Skip to content

Commit

Permalink
chore: addded github action: deploy-main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
chan9yu committed Jan 15, 2025
1 parent 007c474 commit 4ce9a24
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: remote ssh command for deploy

on:
push:
branches: [main]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
# 레포지토리 체크아웃
- name: Checkout repository
uses: actions/checkout@v2

# SSH를 사용하여 스크립트 실행
- name: executing remote ssh commands using key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
./git/react-api-cicd/scripts/deploy.sh
23 changes: 23 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

npm -g install yarn

source ~/.bash_profile
cd ~/git/react-api-cicd/
git pull origin main

# front-end
cd frontend/
yarn install
yarn build
cp -rf dist/* ../backend/public

# back-end
cd ../backend/
yarn install

# pm2
pm2 stop react-api-cicd
pm2 start bin/www --name react-api-cicd --update-env
sleep 2
pm2 list

0 comments on commit 4ce9a24

Please sign in to comment.