name: Deploy Frontend to GitHub (for Vercel) on: push: branches: - main - master paths: # Trigger only when frontend files change - 'frontend/**' workflow_dispatch: jobs: deploy-frontend: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Configure Git run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" - name: Extract and Push Frontend env: # Set your frontend repository here (format: username/repo) FRONTEND_REPO: ${{ secrets.FRONTEND_REPO }} # GitHub PAT with repo permissions for cross-repo push DEPLOY_TOKEN: ${{ secrets.FRONTEND_DEPLOY_TOKEN }} run: | # Default repo if secret not set REPO=${FRONTEND_REPO:-"Nivakaran-S/modelx-frontend"} # Create a new directory for frontend-only repo mkdir -p /tmp/frontend-deploy # Copy frontend contents (not the folder itself) cp -r frontend/* /tmp/frontend-deploy/ # Copy root configs needed for Next.js if they exist [ -f "frontend/.gitignore" ] && cp frontend/.gitignore /tmp/frontend-deploy/ || true # Create .env.production with API URL placeholder echo "NEXT_PUBLIC_API_URL=\${NEXT_PUBLIC_API_URL:-https://nivakaran-modelx.hf.space}" > /tmp/frontend-deploy/.env.production cd /tmp/frontend-deploy # Initialize git repo git init git add . git commit -m "Deploy frontend from main repo - $(date +'%Y-%m-%d %H:%M:%S')" # Push to frontend repo git remote add origin https://x-access-token:${DEPLOY_TOKEN}@github.com/${REPO}.git git branch -M main git push origin main --force - name: Verify Deployment if: success() run: echo "✅ Successfully pushed frontend to GitHub repository for Vercel deployment!" - name: Deployment Failed if: failure() run: echo "❌ Failed to push frontend. Check if FRONTEND_DEPLOY_TOKEN and FRONTEND_REPO secrets are configured."