Skip to content

Commit f2a532d

Browse files
committed
Fix GitHub Pages deployment - remove environment protection
1 parent 534c48e commit f2a532d

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ jobs:
4646
path: ./frontend/dist
4747

4848
deploy:
49-
environment:
50-
name: github-pages
51-
url: ${{ steps.deployment.outputs.page_url }}
5249
runs-on: ubuntu-latest
5350
needs: build
51+
permissions:
52+
pages: write
53+
id-token: write
5454

5555
steps:
5656
- name: Deploy to GitHub Pages

DEPLOYMENT.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ If you prefer not to use Render, here are alternatives:
204204
1. Check the Actions tab in your GitHub repository
205205
2. Verify `VITE_SOCKET_URL` secret is set correctly
206206
3. Ensure all dependencies are in `package.json`
207+
4. **Environment protection rules error**: If you see "Branch 'main' is not allowed to deploy to github-pages due to environment protection rules", the workflow file has been updated to remove the environment reference. Make sure you have the latest version of `.github/workflows/deploy.yml`
208+
207209

208210
### Backend not responding
209211

QUICK_DEPLOY.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Quick Deployment Reference
2+
3+
## Your Backend URL
4+
```
5+
https://autolearn-cwhp.onrender.com
6+
```
7+
8+
## Steps to Complete Deployment
9+
10+
### 1. Add GitHub Secret
11+
1. Go to your GitHub repository: **Settings****Secrets and variables****Actions**
12+
2. Click **"New repository secret"**
13+
3. Add:
14+
- **Name**: `VITE_SOCKET_URL`
15+
- **Value**: `https://autolearn-cwhp.onrender.com`
16+
17+
### 2. Commit and Push
18+
```bash
19+
git add .
20+
git commit -m "Fix GitHub Pages deployment - remove environment protection"
21+
git push origin main
22+
```
23+
24+
### 3. Update Backend CORS
25+
Edit `backend/index.js` and update the CORS configuration to include your GitHub Pages URL:
26+
27+
```javascript
28+
const io = new Server(server, {
29+
cors: {
30+
origin: [
31+
"http://localhost:5173", // Local development
32+
"https://anant1711.github.io" // Production (replace with your GitHub username)
33+
],
34+
methods: ["GET", "POST"]
35+
}
36+
});
37+
```
38+
39+
Then commit and push to trigger Render redeploy.
40+
41+
### 4. Access Your Site
42+
Your site will be available at: `https://anant1711.github.io/AutoLearn/`
43+
44+
## What Was Fixed
45+
46+
The deployment error "Branch 'main' is not allowed to deploy to github-pages due to environment protection rules" was caused by the GitHub Actions workflow trying to use a protected environment.
47+
48+
**Solution**: Removed the `environment` reference from `.github/workflows/deploy.yml` and moved permissions to the job level instead.
49+
50+
## Testing Locally with Production Backend
51+
52+
If you want to test with the production backend locally:
53+
54+
Edit `frontend/.env`:
55+
```env
56+
VITE_SOCKET_URL=https://autolearn-cwhp.onrender.com
57+
```
58+
59+
Then run:
60+
```bash
61+
cd frontend
62+
npm run dev
63+
```

0 commit comments

Comments
 (0)