|
1 | 1 | # GitHub Secrets Configuration |
2 | 2 |
|
3 | | -This document lists all the secrets and environment variables required for the CI/CD pipelines. |
| 3 | +This document describes the required secrets for the CI/CD pipeline. |
4 | 4 |
|
5 | 5 | ## Required Secrets |
6 | 6 |
|
7 | | -### Repository Secrets |
8 | | - |
9 | 7 | Configure these secrets in your GitHub repository settings (`Settings > Secrets and variables > Actions`): |
10 | 8 |
|
11 | | -#### Artifactory Configuration |
12 | | -- **`ARTIFACTORY_URL`** - URL of your artifactory instance (e.g., `https://your-company.jfrog.io/artifactory/api/pub/dart`) |
13 | | -- **`ARTIFACTORY_USERNAME`** - Username for artifactory authentication |
14 | | -- **`ARTIFACTORY_PASSWORD`** - Password or API key for artifactory authentication |
| 9 | +### pub.dev Configuration |
| 10 | +- **`PUB_CREDENTIALS`** - Complete credentials JSON file for pub.dev publishing (includes refresh token for auto-renewal) |
15 | 11 |
|
16 | | -#### Optional Notification Secrets |
17 | | -- **`SLACK_WEBHOOK_URL`** - Slack webhook for release notifications (optional) |
18 | | -- **`DISCORD_WEBHOOK_URL`** - Discord webhook for release notifications (optional) |
| 12 | +### Optional Notification Secrets |
| 13 | +- **`SLACK_WEBHOOK_URL`** - Webhook URL for Slack notifications (optional) |
| 14 | +- **`DISCORD_WEBHOOK_URL`** - Webhook URL for Discord notifications (optional) |
19 | 15 |
|
20 | | -### Environment Variables |
| 16 | +## Setting Up Secrets |
21 | 17 |
|
22 | | -These are automatically available in GitHub Actions: |
| 18 | +### 1. pub.dev Setup |
23 | 19 |
|
24 | | -- **`GITHUB_TOKEN`** - Automatically provided by GitHub Actions |
25 | | -- **`GITHUB_ACTOR`** - Username of the person who triggered the workflow |
26 | | -- **`GITHUB_REF`** - Branch or tag ref that triggered the workflow |
| 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 | + ``` |
27 | 28 |
|
28 | | -## Setting Up Secrets |
| 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 |
29 | 33 |
|
30 | | -### 1. Artifactory Setup |
| 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 |
31 | 39 |
|
| 40 | +### 2. Notification Setup (Optional) |
| 41 | + |
| 42 | +#### Slack |
32 | 43 | ```bash |
33 | | -# Example artifactory URL formats: |
34 | | -# JFrog Cloud: https://your-company.jfrog.io/artifactory/api/pub/dart |
35 | | -# Self-hosted: https://artifactory.your-company.com/artifactory/api/pub/dart |
| 44 | +# Create a Slack webhook in your workspace |
| 45 | +# Add the webhook URL as SLACK_WEBHOOK_URL secret |
36 | 46 | ``` |
37 | 47 |
|
38 | | -### 2. GitHub Repository Settings |
39 | | - |
40 | | -1. Go to your repository on GitHub |
41 | | -2. Click on `Settings` tab |
42 | | -3. Navigate to `Secrets and variables > Actions` |
43 | | -4. Click `New repository secret` |
44 | | -5. Add each secret with the exact name listed above |
45 | | - |
46 | | -### 3. Testing Secrets |
47 | | - |
48 | | -You can test if secrets are properly configured by running the manual release workflow with dry-run enabled. |
| 48 | +#### Discord |
| 49 | +```bash |
| 50 | +# Create a Discord webhook in your server |
| 51 | +# Add the webhook URL as DISCORD_WEBHOOK_URL secret |
| 52 | +``` |
49 | 53 |
|
50 | 54 | ## Security Best Practices |
51 | 55 |
|
52 | | -### Secret Management |
53 | | -- Use API keys instead of passwords when possible |
54 | | -- Rotate secrets regularly |
55 | | -- Use least-privilege access for artifactory users |
| 56 | +- Use tokens with minimal required permissions |
| 57 | +- Rotate tokens regularly |
56 | 58 | - Never log secret values in workflows |
| 59 | +- Use environment-specific secrets when possible |
57 | 60 |
|
58 | | -### Access Control |
59 | | -- Limit repository access to trusted contributors |
60 | | -- Use branch protection rules for main/develop branches |
61 | | -- Require PR reviews for sensitive changes |
| 61 | +## Verification |
62 | 62 |
|
63 | | -### Monitoring |
64 | | -- Monitor artifactory access logs |
65 | | -- Set up alerts for failed releases |
66 | | -- Review workflow logs regularly |
| 63 | +Test your setup: |
| 64 | +```bash |
| 65 | +# Dry run to test authentication |
| 66 | +melos publish --dry-run |
| 67 | +``` |
67 | 68 |
|
68 | 69 | ## Troubleshooting |
69 | 70 |
|
70 | 71 | ### Common Issues |
71 | 72 |
|
72 | | -#### Artifactory Authentication Failed |
| 73 | +#### pub.dev Authentication Failed |
73 | 74 | ``` |
74 | | -Error: 401 Unauthorized |
| 75 | +Error: 401 Unauthorized when accessing https://pub.dartlang.org |
75 | 76 | ``` |
76 | | -**Solution:** Check `ARTIFACTORY_USERNAME` and `ARTIFACTORY_PASSWORD` are correct. |
| 77 | +**Solution:** Check that `PUB_CREDENTIALS` contains valid JSON with both accessToken and refreshToken. |
77 | 78 |
|
78 | | -#### Artifactory URL Not Found |
| 79 | +#### Token Expired |
79 | 80 | ``` |
80 | | -Error: Could not resolve host |
| 81 | +Error: Token has expired |
81 | 82 | ``` |
82 | | -**Solution:** Verify `ARTIFACTORY_URL` is correct and accessible. |
| 83 | +**Solution:** Generate a new token using `dart pub login` and update the secret. |
83 | 84 |
|
84 | 85 | #### Missing Permissions |
85 | 86 | ``` |
86 | | -Error: Resource not accessible by integration |
| 87 | +Error: Insufficient permissions to publish package |
87 | 88 | ``` |
88 | | -**Solution:** Ensure the repository has proper permissions and the `GITHUB_TOKEN` has write access. |
| 89 | +**Solution:** Ensure you have publisher permissions for the package on pub.dev. |
89 | 90 |
|
90 | | -### Debug Mode |
| 91 | +## Token Management |
91 | 92 |
|
92 | | -To enable debug logging in workflows, add this secret: |
93 | | -- **`ACTIONS_RUNNER_DEBUG`** = `true` |
| 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` |
94 | 97 |
|
95 | | -## Workflow Permissions |
| 98 | +### Monitoring |
| 99 | +- Monitor pub.dev package dashboard |
| 100 | +- Set up alerts for failed releases |
| 101 | +- Review workflow logs regularly |
96 | 102 |
|
97 | | -The workflows require these permissions: |
| 103 | +## Package Publishing Process |
98 | 104 |
|
99 | | -```yaml |
100 | | -permissions: |
101 | | - contents: write # For creating commits and tags |
102 | | - packages: write # For publishing packages |
103 | | - pull-requests: write # For commenting on PRs |
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 |
105 | 109 |
|
106 | | -These are automatically configured in the workflow files. |
| 110 | +For more details, see the main [CI/CD documentation](../docs/CI-CD.md). |
0 commit comments