Skip to content

Commit 95675f2

Browse files
Copilotnchalla3
andcommitted
Fix workflow to handle pull requests from forks gracefully
Co-authored-by: nchalla3 <45720973+nchalla3@users.noreply.github.com>
1 parent 4fd4a74 commit 95675f2

2 files changed

Lines changed: 50 additions & 1 deletion

File tree

.github/workflows/firebase-preview-deploy.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ jobs:
6868
echo "Generated channel name: $CHANNEL"
6969
7070
# Install Firebase CLI and deploy to preview channel
71+
# Only run if secrets are available (not on forks)
7172
- name: Deploy to Firebase preview channel
7273
id: firebase-deploy
74+
# Skip deployment for pull requests from forks (secrets are not available)
75+
if: ${{ secrets.FIREBASE_TOKEN != '' && secrets.FIREBASE_PROJECT_ID != '' }}
7376
env:
7477
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
7578
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
@@ -93,6 +96,30 @@ jobs:
9396
echo "$DEPLOY_OUTPUT"
9497
exit 1
9598
fi
99+
100+
# Add note when deployment is skipped
101+
- name: Deployment skipped notice
102+
if: ${{ secrets.FIREBASE_TOKEN == '' || secrets.FIREBASE_PROJECT_ID == '' }}
103+
run: |
104+
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
105+
## ℹ️ Firebase Deployment Skipped
106+
107+
Firebase deployment was skipped because the required secrets are not available.
108+
This typically happens for pull requests from forked repositories.
109+
110+
**Build Status:** ✅ Build completed successfully
111+
112+
### What was tested:
113+
- ✅ Dependencies installed
114+
- ✅ Application built successfully
115+
- ✅ Tests passed
116+
117+
### Note for maintainers:
118+
To deploy a preview for this PR, a maintainer needs to either:
119+
1. Close and reopen the PR from the main repository, or
120+
2. Manually trigger a deployment after merging
121+
EOF
122+
echo "⚠️ Firebase deployment skipped - secrets not available (likely a fork PR)"
96123
97124
# Add preview URL to job summary
98125
- name: Add deployment summary

FIREBASE_DEPLOY_README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,26 @@ firebase login:ci
4141

4242
- **Push to any branch**: Creates preview deploy
4343
- **Pull requests**: Creates preview deploy for PR branch
44-
- **Concurrency**: Cancels previous deployments for same branch to avoid conflicts
44+
- **Concurrency**: Cancels previous deployments for same branch to avoid conflicts
45+
46+
## Important: Pull Requests from Forks
47+
48+
**GitHub Actions does not provide access to repository secrets for pull requests from forked repositories** for security reasons.
49+
50+
### What this means:
51+
- PRs from forks will **build successfully** but **skip Firebase deployment**
52+
- The workflow will show a notice explaining why deployment was skipped
53+
- All other checks (build, tests) will still run to verify code quality
54+
55+
### For maintainers:
56+
If you need to preview changes from a forked PR:
57+
1. Review the code changes first for security
58+
2. Create a branch in the main repository with the changes
59+
3. Push to that branch to trigger a preview deployment
60+
4. Alternatively, merge the PR and the deployment will run on the main branch
61+
62+
### For contributors:
63+
If you're submitting a PR from a fork:
64+
- Your build will be verified automatically
65+
- Deployment preview will be created after a maintainer reviews your PR
66+
- This is a security feature to protect repository secrets

0 commit comments

Comments
 (0)