This guide explains how to securely handle pull requests from external contributors that require access to repository secrets for testing.
External contributors cannot access repository secrets (like NETBIRD_API_TOKEN) for security reasons. This prevents integration tests from running on their PRs, which could miss important issues.
We've implemented a secure approval system that:
- Runs basic tests automatically - Unit tests, linting, Docker builds (no secrets needed)
- Requires manual approval - Integration tests with secrets only run after maintainer approval
- Uses label-based approval - Simple workflow using GitHub labels
- Provides clear feedback - Contributors know what's happening and why
- Manual Review Required: All external PRs require code review before secrets access
- Label-Based Approval: Uses
approved-for-testinglabel to control access - Environment Protection: Uses GitHub environments for additional security
- Audit Trail: All approvals are logged with reviewer information
- Clear Documentation: Contributors understand the process
Without Approval (Automatic):
- ✅ Unit tests
- ✅ Linting and code quality
- ✅ Docker image builds
- ✅ Helm chart validation (with dummy values)
- ✅ Performance and benchmark tests
With Approval (Comment /approve or add label):
- 🔒 Integration tests with real NetBird API
- 🔒 Docker Compose full stack tests
- 🔒 Helm chart tests with real secrets
- 🔒 End-to-end functionality tests
- Review the PR code changes thoroughly
- Choose your preferred approval method:
Option 1: Comment Approval (Recommended)
/approve
Or comment any of these:
/approve-testingapproved for testingapprove for testing
Option 2: Manual Label
Add the approved-for-testing label via GitHub UI
- Monitor test results
Before approving any external PR, ensure:
- Code Review Complete: All changes have been reviewed
- No Malicious Code: No suspicious or harmful code patterns
- No Secret Exposure: Code doesn't log or expose secrets
- Trusted Contributor: Author has good GitHub history
- Reasonable Changes: Changes are within scope and reasonable
- No Workflow Modifications: No changes to
.github/workflows/without extra scrutiny
When you open a PR from a fork:
- Basic tests run immediately - No waiting needed
- Security check comment appears - Explains the process
- Integration tests require approval - Need maintainer review
- Maintainer can approve via comment - Simple
/approvecomment - Clear status updates - You'll see what's happening
To get faster approval:
- Write clear PR descriptions - Explain what and why
- Keep changes focused - Smaller PRs are easier to review
- Add tests - Show you've tested your changes
- Follow guidelines - Check CONTRIBUTING.md
- Be patient - Maintainers review as time permits
Once approved:
- All tests run automatically - Including integration tests
- Future commits auto-approved - No need to re-approve
- Full test feedback - You'll see all test results
.github/workflows/external-pr.yml- Main external PR workflow- Security first approach - Uses
pull_request_targetsafely - Environment protection - Uses GitHub environments
- Comprehensive testing - Covers all test scenarios
External PR → Security Check → Basic Tests (Always)
↓
Approval Required → Full Tests (If Approved)
↓
Test Results → Feedback to PR
approved-for-testing- Main approval label- Persistent approval - Applies to all future commits
- Easy to manage - Can be added/removed as needed
All test results are:
- Visible in PR - Comments and checks show status
- Documented in summaries - Clear pass/fail information
- Linked to workflows - Easy to debug failures
- GitHub audit log - All label changes are logged
- PR comments - Optional approval comments with timestamps
- Workflow history - Complete test execution history
Can't add label:
- Check repository permissions
- Ensure you're a maintainer
- Try adding label manually in GitHub UI
Tests still don't run:
- Verify label was added successfully
- Check workflow run logs
- Ensure PR is from external repository
- Check workflow logs - Look for error messages
- Review PR comments - Automated feedback explains issues
- Ask in discussions - Use GitHub Discussions for questions
- Regular Review Schedule - Check for external PRs regularly
- Document Decisions - Use approval comments for audit trail
- Monitor Test Results - Follow up on test failures
- Update Documentation - Keep this guide current
- Follow Contributing Guidelines - Read CONTRIBUTING.md
- Test Locally First - Run tests before submitting
- Clear Communication - Explain changes in PR description
- Be Responsive - Address review feedback promptly
- Credential Theft - Prevents malicious code from accessing secrets
- Resource Abuse - Limits who can run expensive tests
- Supply Chain Attacks - Requires human review of all external code
- Accidental Exposure - Prevents secrets from being logged or exposed
- Social Engineering - Still requires careful code review
- Compromised Maintainer - Depends on maintainer security
- Repository Compromise - Broader security measures needed
Consider implementing:
- Two-person approval - Require multiple maintainer approvals
- Time delays - Wait period before approval takes effect
- Automated security scanning - Additional security checks
- Limited scope secrets - Use test-specific tokens when possible
This system balances security with contributor experience by:
- Keeping barriers low - Most tests run without approval
- Requiring human review - Sensitive tests need approval
- Providing clear feedback - Everyone knows what's happening
- Maintaining security - Secrets are protected from malicious code
The result is a secure, maintainable process that welcomes external contributions while protecting repository secrets and resources.