|
|
name: Deploy Frontend to GitHub (for Vercel) |
|
|
|
|
|
on: |
|
|
push: |
|
|
branches: |
|
|
- main |
|
|
- master |
|
|
paths: |
|
|
|
|
|
- '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: |
|
|
|
|
|
FRONTEND_REPO: ${{ secrets.FRONTEND_REPO }} |
|
|
|
|
|
DEPLOY_TOKEN: ${{ secrets.FRONTEND_DEPLOY_TOKEN }} |
|
|
run: | |
|
|
# Default repo if secret not set |
|
|
REPO=${FRONTEND_REPO:-"Nivakaran-S/modelx-frontend"} |
|
|
|
|
|
|
|
|
mkdir -p /tmp/frontend-deploy |
|
|
|
|
|
|
|
|
cp -r frontend/* /tmp/frontend-deploy/ |
|
|
|
|
|
|
|
|
[ -f "frontend/.gitignore" ] && cp frontend/.gitignore /tmp/frontend-deploy/ || true |
|
|
|
|
|
|
|
|
echo "NEXT_PUBLIC_API_URL=\${NEXT_PUBLIC_API_URL:-https://nivakaran-modelx.hf.space}" > /tmp/frontend-deploy/.env.production |
|
|
|
|
|
cd /tmp/frontend-deploy |
|
|
|
|
|
|
|
|
git init |
|
|
git add . |
|
|
git commit -m "Deploy frontend from main repo - $(date +'%Y-%m-%d %H:%M:%S')" |
|
|
|
|
|
|
|
|
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." |
|
|
|