Create main.yml
This commit is contained in:
parent
63a0d19ad7
commit
4b0648a918
1 changed files with 41 additions and 0 deletions
41
.github/workflows/main.yml
vendored
Normal file
41
.github/workflows/main.yml
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
name: Deploy React Vite App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build the app
|
||||
run: npm run build
|
||||
|
||||
- name: Deploy to VPS
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
VPS_USER: ${{ secrets.SSH_USERNAME }}
|
||||
VPS_HOST: ${{ secrets.SSH_HOST }}
|
||||
VPS_PORT: ${{ secrets.SSH_PORT }}
|
||||
VPS_PATH: ${{ secrets.PATH}}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
ssh-keyscan -H $VPS_HOST >> ~/.ssh/known_hosts
|
||||
rsync -avz --delete dist/ $VPS_USER@$VPS_HOST:$VPS_PATH
|
||||
ssh $VPS_USER@$VPS_HOST:$VPS_PORT "cd $VPS_PATH && npm install --production "
|
||||
# && pm2 restart all"
|
||||
Loading…
Add table
Add a link
Reference in a new issue