|
| 1 | +# Setting Up Vercel Deployment via GitHub Actions |
| 2 | + |
| 3 | +## ✅ What Was Added |
| 4 | + |
| 5 | +A new `deploy-vercel` job was added to `.github/workflows/ci.yml` that automatically deploys to Vercel after a successful build when you push to the `main` branch. |
| 6 | + |
| 7 | +## 🔑 Required Secret: VERCEL_TOKEN |
| 8 | + |
| 9 | +You need to add your Vercel token as a GitHub secret for the workflow to work. |
| 10 | + |
| 11 | +### Step 1: Generate Vercel Token |
| 12 | + |
| 13 | +1. Go to: https://vercel.com/account/tokens |
| 14 | +2. Click **"Create Token"** |
| 15 | +3. Give it a name: `GitHub Actions Deployment` |
| 16 | +4. Copy the token (you won't see it again!) |
| 17 | + |
| 18 | +### Step 2: Add Token to GitHub |
| 19 | + |
| 20 | +1. Go to your GitHub repository: https://github.com/stellar-nexus-experience/demo-suite |
| 21 | +2. Click **Settings** (repository settings) |
| 22 | +3. Go to **Secrets and variables** → **Actions** |
| 23 | +4. Click **"New repository secret"** |
| 24 | +5. Name: `VERCEL_TOKEN` |
| 25 | +6. Value: paste the token you copied |
| 26 | +7. Click **"Add secret"** |
| 27 | + |
| 28 | +### Step 3: Verify Setup |
| 29 | + |
| 30 | +1. Push a commit to `main` branch (or make any change) |
| 31 | +2. Go to **Actions** tab in GitHub |
| 32 | +3. You should see the CI workflow running |
| 33 | +4. Once it completes, check Vercel dashboard for the new deployment |
| 34 | + |
| 35 | +## 🎯 How It Works |
| 36 | + |
| 37 | +```yaml |
| 38 | +deploy-vercel: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + needs: build # Only runs after build succeeds |
| 41 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' # Only on main branch pushes |
| 42 | + |
| 43 | + steps: |
| 44 | + - Checkout code |
| 45 | + - Setup Node.js |
| 46 | + - Install dependencies |
| 47 | + - Deploy on Vercel using your token |
| 48 | +``` |
| 49 | +
|
| 50 | +## ✅ Expected Behavior |
| 51 | +
|
| 52 | +- ✅ On push to `main`: Build → Deploy to Vercel production |
| 53 | +- ✅ On pull requests: Build only (no deployment) |
| 54 | +- ✅ On other branches: Nothing (workflow doesn't run) |
| 55 | +- ✅ Failed builds: No deployment (prevents broken deployments) |
| 56 | + |
| 57 | +## 🚨 Troubleshooting |
| 58 | + |
| 59 | +### "Secret VERCEL_TOKEN not found" |
| 60 | +- Make sure you added the secret in the GitHub repository settings |
| 61 | +- Secret name must be exactly: `VERCEL_TOKEN` |
| 62 | +- Check you're adding it to the correct repository |
| 63 | + |
| 64 | +### "Deployment failed" |
| 65 | +- Check Vercel token is valid and not expired |
| 66 | +- Verify the token has deployment permissions |
| 67 | +- Check GitHub Actions logs for specific errors |
| 68 | + |
| 69 | +### "Action runs but nothing deploys" |
| 70 | +- Verify the `if` condition: `github.ref == 'refs/heads/main'` |
| 71 | +- Check you're pushing to `main` branch, not another branch |
| 72 | +- Make sure `github.event_name == 'push'` (not pull_request) |
| 73 | + |
| 74 | +### Still having issues? |
| 75 | +1. Check GitHub Actions logs: Repository → Actions → Select workflow run |
| 76 | +2. Check Vercel dashboard for any errors |
| 77 | +3. Verify Vercel token hasn't expired |
| 78 | + |
| 79 | +## 📝 Important Notes |
| 80 | + |
| 81 | +- **Token Security**: Never commit your Vercel token to git! Use GitHub secrets. |
| 82 | +- **Token Expiry**: Vercel tokens don't expire, but you can revoke them anytime |
| 83 | +- **Build First**: Deployment only happens after a successful build |
| 84 | +- **Production Only**: This deploys to Vercel production environment (`--prod`) |
| 85 | + |
| 86 | +## 🎉 Success Criteria |
| 87 | + |
| 88 | +✅ Workflow appears in GitHub Actions tab |
| 89 | +✅ Build job completes successfully |
| 90 | +✅ Deploy job runs after build |
| 91 | +✅ New deployment appears in Vercel dashboard |
| 92 | +✅ Website updates automatically on each push |
| 93 | + |
| 94 | +## 🔄 Alternative: Manual Vercel Setup |
| 95 | + |
| 96 | +If you prefer to use Vercel's built-in GitHub integration instead: |
| 97 | +1. Follow instructions in `VERCEL_ORG_SETUP.md` |
| 98 | +2. Vercel will auto-deploy on pushes |
| 99 | +3. You can remove the GitHub Actions deploy job |
| 100 | + |
| 101 | +Having both won't hurt, but Vercel's native integration is usually easier! |
| 102 | + |
0 commit comments