Skip to content

Untrack frontend/.env #359

Untrack frontend/.env

Untrack frontend/.env #359

Workflow file for this run

# .github/workflows/deploy.yml
name: Build and Deploy
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'frontend/package-lock.json'
- name: Install dependencies
run: cd frontend && npm ci
- name: Build application
env:
API_BASE: ${{ secrets.API_BASE }}
run: cd frontend && npm run build
- name: Run tests (if you have any)
run: cd frontend && npm test --if-present
deploy:
needs: build
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
environment: production # Creates deployment status
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VM_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.VM_HOST }} >> ~/.ssh/known_hosts
- name: Deploy to VM
run: |
ssh -i ~/.ssh/deploy_key ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }} << 'EOF'
cd ~/complex-stories-main
git pull origin main
cd frontend
npm ci --only=production
npm install
npm run build
cd ..
pm2 restart ecosystem.config.json
# Wait for app to start
sleep 10
# Health check
if pm2 describe complex-stories-main | grep -q "online"; then
echo "✅ Deployment successful - app is online"
exit 0
else
echo "❌ Deployment failed - app not online"
exit 1
fi
EOF
- name: Verify deployment
run: |
echo "Deployment completed successfully!"