Skip to content

Commit

Permalink
add auto update from deployment via ssh (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinpham5614 authored May 10, 2024
1 parent 7665a6d commit 9bdc1ad
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Continuous Deployment via SSH
on:
[workflow_dispatch]
# push:
# branches:
# - main

jobs:
deploy:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

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

- name: Install SSH Key
run: |
mkdir -p ~/.ssh/
echo "${{ secrets.DEPLOYUSERSSHKEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
- name: Execute Deployment Commands
run: |
ssh -o StrictHostKeyChecking=no [email protected] << 'EOF'
source ~/.profile || true
source ~/.bashrc || true
# Ensure you're in the correct directory
cd ~/belindasFrontEnd
# Fetch the latest changes
git pull origin main
# Activate the Node.js version managed by nvm
source ~/.nvm/nvm.sh
nvm use ${{ matrix.node-version }}
# Install any new dependencies using npm from nvm
npm install
# Build the project
npm run build
# Restart the application with PM2
pm2 restart belindas-frontend
EOF

0 comments on commit 9bdc1ad

Please sign in to comment.