4.4 KiB
Executable File
GitHub Environment Protection Setup
Status: Manual Configuration Required Priority: HIGH Estimated Time: 30 minutes
Overview
This document provides instructions for setting up GitHub environment protection rules for the release job in the GoReleaser workflow. This adds an additional security layer to prevent unauthorized or accidental releases.
Why This Is Important
Currently, the release-goreleaser.yml workflow has broad permissions (contents: write, packages: write) without environment protection. This means:
- Anyone with write access can trigger a release
- No approval gate exists before publishing to production
- No audit trail for release decisions
Environment protection adds:
- ✅ Required reviewers before release
- ✅ Restricted to specific branches/tags
- ✅ Audit log of approvals
- ✅ Prevention of accidental releases
Setup Instructions
Step 1: Access Repository Settings
- Navigate to: https://github.com/Wikid82/Charon/settings/environments
- Click "New environment"
Step 2: Create "release" Environment
- Environment name:
release - Click "Configure environment"
Step 3: Configure Protection Rules
Required Reviewers
- Under "Environment protection rules", enable "Required reviewers"
- Add at least 1-2 trusted maintainers who must approve releases
- Recommended reviewers:
- Repository owner (@Wikid82)
- Senior maintainers with release authority
Deployment Branches and Tags
- Under "Deployment branches and tags", select "Protected branches and tags only"
- This ensures releases can only be triggered from tags matching
v*pattern - Click "Add deployment branch or tag rule"
- Pattern:
v*(matches v1.0.0, v2.1.3-beta, etc.)
Wait Timer (Optional)
- "Wait timer": Consider adding a 5-minute wait timer for additional safety
- This provides a brief window to cancel accidental releases
Step 4: Update Workflow File
The workflow file already references the environment in the correct location. No code changes needed:
jobs:
goreleaser:
runs-on: ubuntu-latest
environment:
name: release
url: https://github.com/${{ github.repository }}/releases
permissions:
contents: write
packages: write
Step 5: Test the Setup
- Create a test tag:
git tag v0.0.1-test && git push origin v0.0.1-test - Verify the workflow run pauses for approval
- Check that the approval request appears in GitHub UI
- Approve the deployment to complete the test
- Delete the test tag:
git tag -d v0.0.1-test && git push origin :refs/tags/v0.0.1-test
Verification Checklist
After setup, verify:
- Environment "release" exists in repository settings
- Required reviewers are configured (at least 1)
- Deployment is restricted to
v*tags - Test release workflow shows approval gate
- Approval notifications are sent to reviewers
- Audit log shows approval history
Troubleshooting
Workflow Fails with "Environment not found"
Cause: Environment name mismatch between workflow file and GitHub settings
Fix: Ensure environment name is exactly release (case-sensitive)
No Approval Request Shown
Cause: User might be self-approving or environment protection not saved Fix:
- Verify protection rules are enabled
- Ensure reviewer is not the same as the person who triggered the workflow
- Check GitHub notifications settings
Can't Add Reviewers
Cause: Insufficient repository permissions Fix: You must be a repository admin to configure environments
Additional Security Recommendations
Consider also implementing:
- Branch Protection: Require PR reviews before merging to
main - CODEOWNERS: Define release approval owners in
.github/CODEOWNERS - Signed Commits: Require GPG-signed commits for release tags
- 2FA: Enforce 2FA for all users with write access
Related Documentation
Status
- Documentation created
- Environment created in GitHub UI
- Required reviewers added
- Deployment branch rules configured
- Test release approval flow validated
Next Action: Repository admin must complete Steps 1-5 in GitHub UI.