|
| 1 | +# GitHub Secrets Configuration |
| 2 | + |
| 3 | +This document describes the required secrets for the CI/CD pipeline. |
| 4 | + |
| 5 | +## Required Secrets |
| 6 | + |
| 7 | +Configure these secrets in your GitHub repository settings (`Settings > Secrets and variables > Actions`): |
| 8 | + |
| 9 | +### pub.dev Configuration |
| 10 | +- **`PUB_CREDENTIALS`** - Complete credentials JSON file for pub.dev publishing (includes refresh token for auto-renewal) |
| 11 | + |
| 12 | +### Optional Notification Secrets |
| 13 | +- **`SLACK_WEBHOOK_URL`** - Webhook URL for Slack notifications (optional) |
| 14 | +- **`DISCORD_WEBHOOK_URL`** - Webhook URL for Discord notifications (optional) |
| 15 | + |
| 16 | +## Setting Up Secrets |
| 17 | + |
| 18 | +### 1. pub.dev Setup |
| 19 | + |
| 20 | +1. **Generate pub.dev token:** |
| 21 | + ```bash |
| 22 | + # Login to pub.dev locally first |
| 23 | + dart pub login |
| 24 | + |
| 25 | + # Get your credentials file |
| 26 | + cat ~/.pub-cache/credentials.json |
| 27 | + ``` |
| 28 | + |
| 29 | +2. **Copy complete credentials:** |
| 30 | + - Copy the ENTIRE JSON content from the credentials.json file |
| 31 | + - Include the `refreshToken` for automatic token renewal |
| 32 | + - This is your `PUB_CREDENTIALS` value |
| 33 | + |
| 34 | +3. **Add to GitHub:** |
| 35 | + - Go to repository Settings > Secrets and variables > Actions |
| 36 | + - Click "New repository secret" |
| 37 | + - Name: `PUB_CREDENTIALS` |
| 38 | + - Value: The complete JSON from step 2 |
| 39 | + |
| 40 | +### 2. Notification Setup (Optional) |
| 41 | + |
| 42 | +#### Slack |
| 43 | +```bash |
| 44 | +# Create a Slack webhook in your workspace |
| 45 | +# Add the webhook URL as SLACK_WEBHOOK_URL secret |
| 46 | +``` |
| 47 | + |
| 48 | +#### Discord |
| 49 | +```bash |
| 50 | +# Create a Discord webhook in your server |
| 51 | +# Add the webhook URL as DISCORD_WEBHOOK_URL secret |
| 52 | +``` |
| 53 | + |
| 54 | +## Security Best Practices |
| 55 | + |
| 56 | +- Use tokens with minimal required permissions |
| 57 | +- Rotate tokens regularly |
| 58 | +- Never log secret values in workflows |
| 59 | +- Use environment-specific secrets when possible |
| 60 | + |
| 61 | +## Verification |
| 62 | + |
| 63 | +Test your setup: |
| 64 | +```bash |
| 65 | +# Dry run to test authentication |
| 66 | +melos publish --dry-run |
| 67 | +``` |
| 68 | + |
| 69 | +## Troubleshooting |
| 70 | + |
| 71 | +### Common Issues |
| 72 | + |
| 73 | +#### pub.dev Authentication Failed |
| 74 | +``` |
| 75 | +Error: 401 Unauthorized when accessing https://pub.dartlang.org |
| 76 | +``` |
| 77 | +**Solution:** Check that `PUB_CREDENTIALS` contains valid JSON with both accessToken and refreshToken. |
| 78 | + |
| 79 | +#### Token Expired |
| 80 | +``` |
| 81 | +Error: Token has expired |
| 82 | +``` |
| 83 | +**Solution:** Generate a new token using `dart pub login` and update the secret. |
| 84 | + |
| 85 | +#### Missing Permissions |
| 86 | +``` |
| 87 | +Error: Insufficient permissions to publish package |
| 88 | +``` |
| 89 | +**Solution:** Ensure you have publisher permissions for the package on pub.dev. |
| 90 | + |
| 91 | +## Token Management |
| 92 | + |
| 93 | +### Rotating Tokens |
| 94 | +1. Generate new token: `dart pub login` |
| 95 | +2. Update GitHub secret with new token |
| 96 | +3. Test with dry-run: `melos publish --dry-run` |
| 97 | + |
| 98 | +### Monitoring |
| 99 | +- Monitor pub.dev package dashboard |
| 100 | +- Set up alerts for failed releases |
| 101 | +- Review workflow logs regularly |
| 102 | + |
| 103 | +## Package Publishing Process |
| 104 | + |
| 105 | +1. **Authentication**: GitHub Actions uses `PUB_TOKEN` to authenticate |
| 106 | +2. **Validation**: Packages are validated before publishing |
| 107 | +3. **Publishing**: Only changed packages are published |
| 108 | +4. **Verification**: Success/failure is reported in workflow logs |
| 109 | + |
| 110 | +For more details, see the main [CI/CD documentation](../docs/CI-CD.md). |
0 commit comments