fix(github): fixec script #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Voodle Frontend to DigitalOcean | |
on: | |
push: | |
branches: [main] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
known_hosts: ${{ secrets.KNOWN_HOSTS }} | |
- name: Deploy Frontend to DigitalOcean | |
env: | |
HOST: ${{ secrets.HOST }} | |
USER: ${{ secrets.USER }} | |
FRONTEND_ENV: ${{ secrets.FRONTEND_ENV }} | |
run: | | |
ssh $USER@$HOST << EOF | |
set -e | |
echo "Starting deployment process..." | |
# Source the user's profile to ensure all necessary environment variables are set | |
echo "Sourcing user profile..." | |
source ~/.profile | |
# Ensure pnpm is in the PATH | |
echo "Setting up PATH..." | |
export PATH="/home/$USER/.npm-global/bin:$PATH" | |
# Navigate to the frontend project directory | |
echo "Changing to project directory..." | |
cd /var/www/voodle/client | |
# Pull the latest changes | |
echo "Pulling latest changes..." | |
git pull origin main | |
# Verify pnpm installation | |
echo "Verifying pnpm installation..." | |
which pnpm | |
pnpm --version | |
# Setup environment | |
echo "Setting up environment..." | |
echo "$FRONTEND_ENV" > .env | |
# Install dependencies | |
echo "Installing dependencies..." | |
pnpm install | |
# Build the project | |
echo "Building the project..." | |
pnpm run build | |
# Restart the frontend service | |
echo "Restarting frontend service..." | |
pm2 describe voodle-frontend > /dev/null && pm2 restart voodle-frontend || pm2 start "pnpm start" --name "voodle-frontend" | |
# Save PM2 process list | |
echo "Saving PM2 process list..." | |
pm2 save | |
echo "Frontend deployment completed successfully" | |
EOF |