attempt #5 #15
This file contains hidden or 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: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| NODE_VERSION: '18' | |
| jobs: | |
| build: | |
| name: Build All Components | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| npm ci --workspace=frontend | |
| npm ci --workspace=backend | |
| - name: Type check backend | |
| run: npm run type-check | |
| - name: Lint all code | |
| run: npm run lint | |
| - name: Build all components | |
| run: npm run build | |
| - name: Test backend build | |
| run: | | |
| if [ ! -f "./backend/dist/index.js" ]; then | |
| echo "❌ Backend build failed - index.js not found" | |
| exit 1 | |
| fi | |
| echo "✅ Backend build successful" | |
| - name: Test frontend build | |
| run: | | |
| if [ ! -f "./frontend/dist/index.html" ]; then | |
| echo "❌ Frontend build failed - index.html not found" | |
| exit 1 | |
| fi | |
| echo "✅ Frontend build successful" | |
| - name: Upload frontend build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: ./frontend/dist | |
| retention-days: 1 | |
| - name: Upload backend build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-build | |
| path: ./backend/dist | |
| retention-days: 1 | |
| deploy-frontend: | |
| name: Deploy Frontend to GitHub Pages | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Download frontend artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: frontend-build | |
| path: ./dist | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./dist | |
| deploy-backend: | |
| name: Prepare Backend for Deployment | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout repo (for deployment scripts) | |
| uses: actions/checkout@v4 | |
| - name: Download backend artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: backend-build | |
| path: ./backend-dist | |
| - name: Create deployment package | |
| run: | | |
| echo "📦 Creating backend deployment package..." | |
| # Create deployment directory | |
| mkdir -p ./backend-deployment | |
| # Copy built files | |
| cp -r ./backend-dist/* ./backend-deployment/ | |
| # Copy package.json for production dependencies | |
| cp ./backend/package.json ./backend-deployment/ | |
| # Copy environment template | |
| cp ./backend/.env.example ./backend-deployment/.env.example | |
| # Create deployment info | |
| cat > ./backend-deployment/DEPLOYMENT_INFO.md << EOF | |
| # Backend Deployment Package | |
| ## Generated: $(date) | |
| ## Commit: ${{ github.sha }} | |
| ## Branch: ${{ github.ref_name }} | |
| ## To deploy: | |
| 1. Upload this folder to your server | |
| 2. Run: npm install --production | |
| 3. Set up environment variables (copy .env.example to .env) | |
| 4. Run: npm start | |
| ## Environment Variables Required: | |
| - NOTION_TOKEN | |
| - NOTION_DATABASE_ID | |
| - NODE_ENV=production | |
| - PORT (optional, defaults to 3001) | |
| EOF | |
| - name: Upload backend deployment package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-deployment-package | |
| path: ./backend-deployment | |
| retention-days: 30 | |
| - name: Display deployment info | |
| run: | | |
| echo "🚀 Backend deployment package created!" | |
| echo "📁 Contents:" | |
| ls -la ./backend-deployment | |
| echo "" | |
| echo "💡 Download the 'backend-deployment-package' artifact to deploy to your server" |